Is it possible to get UNIX time from such date 2011-02-27 02:04:46? [duplicate]
Mktime and other functions give wrong answer for such a date like 2011-02-27 02:04:46;
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
Use strtotime
$time = '2011-02-27 02:04:46';
strtotime($time);
This will also work (if you need this to run from the unix shell):
date +%T
This will show the time like:
14:20:18
精彩评论