Is there any function in PHP that eithe开发者_开发技巧r takes a date and turns it into a time stamp, or can simply take a date in one format and change it into another format? I have a set of dates in the format 'm d', which I want to change to 'l, F d, Y'.
I will need this with dates in other formats as well, so a function that lets me give it a date, input format and output format.
Try strtotime ( http://www.php.net/strtotime )
DateTime::createFromFormat
Returns new DateTime object formatted according to the specified format
For output in a new format you have
DateTime::format
Or for a timestamp
DateTime::getTimestamp
use strtotime() and put it back in the date function like this:
date("l, F d, Y",strtotime($YOUR_MD_DATE));
Regards,
Dennis M.
精彩评论