getCollectionDatePublic - RFC 3339 formatting required

Permalink
I am writing a data feed using the page list functionality, and I need to change the format the Date time of the getCollectionDatePublic value to:

eg: 2000-01-01T00:00:00Z

i.e. Adding a 'T' after the date, and a 'Z' after the time. This is to adhere to RFC 3339 date/time formatting (http://tools.ietf.org/html/rfc3339).

Can anyone point me in the best direction? I'm presuming I'll need a custom date-time helper here, but I'm unsure as to the correct syntax I'll need to use.

Any advice would be great!

Thanks.

drbiskit
 
beebs93 replied on at Permalink Best Answer Reply
beebs93
I had to deal with RFC3339 time formats recently and made an override date helper - hope this helps:

<?php
defined('C5_EXECUTE') or die('Access Denied.');
class DateHelper extends Concrete5_Helper_Date{
   /**
    * Converts a numerical timestamp to a RFC3339 timestamp
    *
    * @see http://stackoverflow.com/questions/5671433/php-time-to-google-calen...
    * @param integer $intTs - A numerical timestamp
    * @return string
    *
    * @author Brad Beebe
    * @since March 8, 2013
    */
   public function timestampToRFC3339($intTs){
      $strDate = date('Y-m-d\TH:i:s', $intTs);
drbiskit replied on at Permalink Reply
drbiskit
Hi beebs93 - This is great, thanks...

Actually I didn't end up having to use a custom/overide helper for my requirements in this case - but your code example did help with getting the formatting I required for outputting the datetime.

<?=htmlspecialchars($p->getCollectionDatePublic("Y-m-d\TH:i:s\Z"));?>


Either way - this was really useful - Nice one, cheers!