Forums

Display Year Only

dbain 03 Jun, 2013
In the old version of ChronoConnectivity, I used the following code in my form to display the year only in my connection.

<?php echo date('Y',strtotime($MyRow->start_date)); ?>

Now I'm migrating to the new version with Joomla 2.5. If I use the same code in the latest version. It always displays the year 1969.

What am I doing wrong?

Joomla 1.5 Version

http://glbthistorymuseum.com/joomla15/index.php?option=com_chronoconnectivity&Itemid=98

Joomla 2.5 Version

http://glbthistorymuseum.com/joomla25/index.php/en/virtual-museum/hiv-timeline
GreyHead 04 Jun, 2013
Hi dbain,

I'm not sure what the correct name now is. Please try $data-> or $row-> in place of $MyRow->

Bob
dbain 04 Jun, 2013
OK, finally figured it out with some help. For anyone else who might need the correct code to list year only. It is:

<?php echo date('Y',strtotime($data['cbody']['start_date'])); ?>


start_date should be replaced with the name of the field you use for your date.
This topic is locked and no more replies can be posted.