Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get UNIX time from such date 2011-02-27 02:04:46? [duplicate]

Tags:

php

Mktime and other functions give wrong answer for such a date like 2011-02-27 02:04:46;

like image 269
good_evening Avatar asked Dec 07 '25 10:12

good_evening


1 Answers

Just use the strtotime() function, or the DateTime class.


Both the two following portions of code :
echo strtotime('2011-02-27 02:04:46');

$dt = new DateTime('2011-02-27 02:04:46');
echo $dt->format('U');

Will give you the same output :

1298768686
like image 194
Pascal MARTIN Avatar answered Dec 09 '25 23:12

Pascal MARTIN