Convert javascript datetime into php datetime
I want to change javascript date
Mon Jun 23 2014 16:17:05 GMT+0530 (India Standard Time)
into PHP datetime. I triedecho date('Y-m-d h:i:s', strtotime($expire_time));
where
$expire_time
is Mon Jun 23 2014 16:17:05 GMT+0530 (India Standard Time)
but it is giving1970-01-01 12:00:00
.Answer :
(India Standard Time)
causes
the trouble with parsing, so you need to remove it from the string before calling date()
. You can use something like:$expire_time = 'Mon Jun 23 2014 16:17:05 GMT+0530 (India Standard Time)';
$expire_time = substr($expire_time, 0, strpos($expire_time, '('));
echo date('Y-m-d h:i:s', strtotime($expire_time));
http://stackoverflow.com/questions/24258876/convert-javascript-datetime-into-php-datetime
COMMENTS