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? Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted December 1, 2010 Share Posted December 1, 2010 <?=date('d M Y', strtotime($val['Created']));?> Quote Link to comment Share on other sites More sharing options...
jkkenzie Posted December 1, 2010 Author Share Posted December 1, 2010 Worked Thanks! Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.