2012 28 Nov 21:00 CET is a weird date / time format. U-D-M? Where do you understand that?
In any case, the DateTime object has a createFromFormat method, which will be better createFromFormat in the following:
$dt = DateTime::createFromFormat("Y d MH:i T", '2012 28 Nov 21:00 CET'); $ts = $dt->getTimestamp(); echo $ts;
Try it here: http://codepad.viper-7.com/NfAmcw
strtotime expects an "English text datetime" (according to the manual ), which YDM is not. Any time strtotime returns false, it just does not understand your string, which is expected in this application. A note on the manual page addresses this issue:
Note:
Dates in m / d / y or dmy formats are eliminated by looking at the separator between the various components: if the separator is slash (/), then the American m / d / y is assumed; whereas if the separator is a dash (-) or a period (.), then the European dmy format is assumed.
To avoid potential ambiguity, it is best to use ISO 8601 (YYYY-MM-DD) dates or DateTime :: createFromFormat () when possible.
Similarly, DateTime is an excellent tool for any interaction with dates or times.
Documentation
source share