How can I convert a date in the following format to a unix timestamp?
Thu, 26 Dec 2013 17:53:05 +0100
Thanks, Regards !
How can I convert a date in the following format to a unix timestamp?
Thu, 26 Dec 2013 17:53:05 +0100
Thanks, Regards !
Use strtotime:
For example,
echo(strtotime("Thu, 26 Dec 2013 17:53:05 +0100"));
will output
1388076785
Verbose version (oop / robust):
$dateString = 'Thu, 26 Dec 2013 17:53:05 +0100';
$date = DateTime::createFromFormat(
DateTime::RSS,
$dateString,
new DateTimeZone('UTC')
);
echo $date->getTimestamp().PHP_EOL // 1388076785
.$date->format('r').PHP_EOL; // Thu, 26 Dec 2013 17:53:05 +0100