I want to convert format d/m/Y - h:i:s A
to a timestamp in PHP.
I tried:
$time = '26/07/2014 - 03:59:23 PM';
$time2 = strtotime($time);
But that returns null
I want to convert format d/m/Y - h:i:s A
to a timestamp in PHP.
I tried:
$time = '26/07/2014 - 03:59:23 PM';
$time2 = strtotime($time);
But that returns null
This is easiest when using the DateTime
class:
$dateString = '26/07/2014 - 03:59:23 PM';
$datetime = DateTime::createFromFormat('d/m/Y - h:i:s A', $dateString);
echo $datetime->getTimestamp();
An example of this code is here.