开发者

What is the opposite of the PHP function date()?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜