I've been trying to convert Twilio's convoluted time format (Wed, 21 Oct 2015 19:19:53 +0000) into timestamp so I can format it into something more digestible in PHP. I've tried various methods but none works.
Can somebody please shed some light?
I've been trying to convert Twilio's convoluted time format (Wed, 21 Oct 2015 19:19:53 +0000) into timestamp so I can format it into something more digestible in PHP. I've tried various methods but none works.
Can somebody please shed some light?
Just use DateTime::createFromFormat($format, $timestring)
, then call getTimestamp()
on the object it returns:
$datetime = DateTime::createFromFormat("D, j M Y G:i:s O", "Wed, 21 Oct 2015 19:19:53 +0000");
//or $datetime = DateTime::createFromFormat("(D, j M Y G:i:s O)", "(Wed, 21 Oct 2015 19:19:53 +0000)");
$timestamp = $datetime->getTimestamp();
And actually, it looks like it is DateTime::RFC1123
format, so you can just do:
$datetime = DateTime::createFromFormat(DateTime::RFC1123, "Wed, 21 Oct 2015 19:19:53 +0000");