开发者

PHP create date object from yyyy-mm-ddThh:mm:ss string

I have a string in the format yyyy-mm-ddThh:mm开发者_Python百科:ss and I want to convert it to a date object. How would I do this?


$date = DateTime::createFromFormat('Y-m-d\TH:i:s', '2010-06-03T14:29:00');


You could use Datetime's createFromFormat() or, if you don't want to go through building the format mask yourself, convert the string into a Unix timestamp using strtotime().


You should be able to use strtotime().


Remember that strtotime() limits you to 1970 january 1st because of the unix timestamp

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜