-twenty Posted November 30, 2009 Share Posted November 30, 2009 Hi all, this is a simple one but it has be stumped. I'm storing the date in my database as 2010-01-01. I'd like it formatted a little nicer when I return the output to the user, so I'm doing this... echo "<td>". date("D, j M", $$ordersrow['requiredby']) ."</td>\r\n"; Though, the returned output is Wed, 31 Dec and not Fri, 1 Jan. Help? Link to comment https://forums.phpfreaks.com/topic/183465-date-format/ Share on other sites More sharing options...
rajivgonsalves Posted November 30, 2009 Share Posted November 30, 2009 you got two $$ signs remove one, also use strtotime on that variable Link to comment https://forums.phpfreaks.com/topic/183465-date-format/#findComment-968439 Share on other sites More sharing options...
-twenty Posted November 30, 2009 Author Share Posted November 30, 2009 Cool, thanks for the info. What I did was generate 1 January 2010 with strtotime and it resulted in 1262325600. I replaced that with 2010-01-01 in the database and the end result is now Fri, 1 Jan. Thanks! Link to comment https://forums.phpfreaks.com/topic/183465-date-format/#findComment-968444 Share on other sites More sharing options...
rajivgonsalves Posted November 30, 2009 Share Posted November 30, 2009 I meant use strtotime on the variable echo "<td>". date("D, j M", strtotime($ordersrow['requiredby'])) ."</td>\r\n"; you do not need to change it in your database Link to comment https://forums.phpfreaks.com/topic/183465-date-format/#findComment-968446 Share on other sites More sharing options...
-twenty Posted November 30, 2009 Author Share Posted November 30, 2009 Oops! Haha. Well, entering it with strtotime directly into the database seems to work fine as well- no one will be looking at the raw data anyways. Both ways would generate the same end result, so were good! Thanks again. Link to comment https://forums.phpfreaks.com/topic/183465-date-format/#findComment-968450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.