RSS feed publishes datetime (GMT) in Unix timestamp format using PHP
2 answers
Is it possible to use PHP functions to create a Unix timestamp (i.e. seconds since Unix Epoch) and then let MySQL process it from there?
PHP: - PHP Documentation
$timestamp = strtotime( 'Sat, 07 Sep 2002 09:42:31 GMT' ); // = 1031391751
MySQL: - MySQL Documentation
... `timestamp` = FROM_UNIXTIME( 1031391751 ) ...
+4
a source to share
From MySQL Manual :
TIMESTAMP tables are displayed in the same format as DATETIME columns. In other words, the screen width is fixed at 19 characters, and the format is "YYYY-MM-DD HH: MM: SS".
the RSS 2.0 specification states that:
All dates in RSS conform to the RFC 822 Date and Time Specification, except that the year can be expressed in two characters or four characters (four preferred).
So, if we have the following RSS date:
$timeRSS = 'Sat, 07 Sep 2002 09:42:31 GMT'; // RFC 822
We need to do the following to convert it to MySQL format TIMESTAMP
:
date_default_timezone_set('GMT'); // make sure we are using the same timezone
date('Y-m-d H:i:s', strtotime($timeRSS)); // 2002-09-07 09:42:31
+2
a source to share