tags:

views:

198

answers:

3

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
+1 Better answer. :)
Tomalak
+1 For the lazy loading :)
nuqqsa
A: 

You should be able to use strtotime().

Tomalak
+2  A: 
$date = DateTime::createFromFormat('Y-m-d\TH:i:s', '2010-06-03T14:29:00');
nuqqsa
+1 for building the actual mask :)
Pekka