I have a string in the format yyyy-mm-ddThh:mm:ss and I want to convert it to a date object. How would I do this?
+3
A:
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()
.
Pekka
2010-06-03 12:27:08
+1 Better answer. :)
Tomalak
2010-06-03 12:28:43
+1 For the lazy loading :)
nuqqsa
2010-06-03 13:27:52