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
精彩评论