xionhack Posted February 6, 2009 Share Posted February 6, 2009 Hello. I'm pulling a date from a database through the php. When I pull it up it will say something like 2009-06-02. What I want it to do is to put it "February the 6th 2009". How can I do that? Thanks! Link to comment https://forums.phpfreaks.com/topic/144026-date-format/ Share on other sites More sharing options...
TheLoveableMonty Posted February 6, 2009 Share Posted February 6, 2009 date('F \t\h\e jS Y'); That's the one. Link to comment https://forums.phpfreaks.com/topic/144026-date-format/#findComment-755715 Share on other sites More sharing options...
xionhack Posted February 6, 2009 Author Share Posted February 6, 2009 What I want is to modify a date that is already in a variable with that format. How can I do it? Thanks! Link to comment https://forums.phpfreaks.com/topic/144026-date-format/#findComment-755721 Share on other sites More sharing options...
anthylon Posted February 6, 2009 Share Posted February 6, 2009 Hello, TheLoveableMonty explained date/time format option. So if you need to apply it you should use the following syntax: date("format string", datevalue); But this will not work in your case as you get string-date from your database. You need to convert it to timestamp in order to use date format option. This would be solution for you: $my_date = strtotime($my_date); echo date('F \t\h\e jS o' , $my_date); Explanation of strtotime function: it parse about any English textual datetime description into a Unix timestamp (PHP 4, PHP 5) int strtotime ( string time [, int now] ); Good luck Link to comment https://forums.phpfreaks.com/topic/144026-date-format/#findComment-755751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.