php - Converting date (with milliseconds) into timestamp -
this question has answer here:
- convert 1 date format in php 12 answers
i have date format '25 may 2016 10:45:53:567'.
i want convert time stamp.
strtotime function returns empty.
$date = '25 may 2016 10:45:53:567'; echo strtotime($date); // returns empty
when removed milliseconds, it's working.
$date = '25 may 2016 10:45:53'; echo strtotime($date); // returns 1464153353
please sort out issue. in advance.
split string:
$date = '25 may 2016 10:45:53:001'; preg_match('/^(.+):(\d+)$/i', $date, $matches); echo 'timestamp: ' . strtotime($matches[1]) . php_eol; echo 'milliseconds: ' . $matches[2] . php_eol; // timestamp: 1464162353 // milliseconds: 001
Comments
Post a Comment