jkkenzie Posted December 1, 2010 Share Posted December 1, 2010 This code gives me 1969-12-31 18:33:30 <?=date('d M Y', $val['Created']);?> and this one gives me 2010-11-04 03:52:54 WHICH IS THE RIGHT ONE - BUT i need to format as above. <?=$val['Created']?> this happens on the same line of code. What is wrong? Link to comment https://forums.phpfreaks.com/topic/220354-datetime/ Share on other sites More sharing options...
MatthewJ Posted December 1, 2010 Share Posted December 1, 2010 <?=date('d M Y', strtotime($val['Created']));?> Link to comment https://forums.phpfreaks.com/topic/220354-datetime/#findComment-1141826 Share on other sites More sharing options...
jkkenzie Posted December 1, 2010 Author Share Posted December 1, 2010 Worked Thanks! Link to comment https://forums.phpfreaks.com/topic/220354-datetime/#findComment-1141828 Share on other sites More sharing options...
Pikachu2000 Posted December 1, 2010 Share Posted December 1, 2010 It would be easier, and more efficient, to format the date in the query string using MySQL's DATE_FORMAT() function. SELECT DATE_FORMAT(`created`, '%m %d %Y') AS created_alias Then the formatted date could be accessed directly through $val['created_alias']. Also, you'd be better off to get out of the habit of using the <?= 'quick-echo' syntax and use the full <?php echo instead. Doing so will save you headaches in the future. Link to comment https://forums.phpfreaks.com/topic/220354-datetime/#findComment-1141837 Share on other sites More sharing options...
jkkenzie Posted December 2, 2010 Author Share Posted December 2, 2010 Thanks for the advice! its an old CMS am still upgrading. Link to comment https://forums.phpfreaks.com/topic/220354-datetime/#findComment-1142225 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.