Date formatting for custom attributes in Page List template

Permalink
Hey all,

I've got a page type (event page) that lists 'start_date' and 'end_date' custom attributes via the date picker. I want to include those attributes in a custom template for the Page List Block. I'm able to achive the default date format, but am a little lost as to how to apply any custom formatting.

First I get the attributes:
$startDate = $cobj->getAttribute('start_date');
$endDate = $cobj->getAttribute('end_date');


then list them:
<p class="date">
    From  <?php echo $startDate; ?> to <?php echo $endDate; ?>
</p>


Which spits out the default - something like this: 2014-08-23 09:30:00 to 2014-08-30 14:30:00.

In my events page I'm using:
From <?php echo $eventdate->getSystemDateTime($c->getCollectionAttributeValue('start_date'), $mask = 'F d Y, g:ia') ?> to <?php echo $eventdate->getSystemDateTime($c->getCollectionAttributeValue('end_date'), $mask = 'F d Y, g:ia') ?>


Which gives me something like August 23 2014, 9:30am TO August 30 2014, 2:30pm - and thats the date format I'm try to get into the Page List template.

Any thoughts on how I can do this?

juddc
View Replies:
hutman replied on at Permalink Reply
hutman
You should be able to do this

<p class="date">
    From  <?php echo date('F j, Y g:ia', $startDate); ?> to <?php echo date('F j, Y g:ia' ,$endDate); ?>
</p>


http://php.net/manual/en/function.date.php...
juddc replied on at Permalink Reply 1 Attachment
juddc
Thanks for taking the time - but no love - I get this on every entry (even ones without custom date attributes) - see attached image.

December 31, 1969 5:00pm to December 31, 1969 5:00pm
hutman replied on at Permalink Reply
hutman
Does this work

<p class="date">
    From  <?php echo date('F j, Y g:ia', strtotime($startDate)); ?> to <?php echo date('F j, Y g:ia' ,strtotime($endDate)); ?>
</p>
juddc replied on at Permalink Reply
juddc
Yes! It does, thanks. Although if no attribute has been filled in for either start_date or end_date, the the same 1969 date appears...