Reputation: 9583
From a rss feed i have either pubdate as well the timestamp:
pubdate:
Thu, 03 May 2012 09:00:00 +0000
timestamp:
1336035600
However when i insert it into the database it's always: 0000-00-00 ETC. This is the query:
$query = "INSERT INTO adafruit_articles VALUES ('', '$title', '$link', '$comments', '$timestamp', '$description', '$content')";
Is my database set up correct?
Upvotes: 1
Views: 134
Reputation: 219894
You need to convert it into a MySQL friendly format. Passing the timestamp to the date()
function makes this easy:
echo date("Y-m-d H:i:s", 1336035600);
Or use the DateTime object:
$date = new DateTime(1336035600);
echo $date->format('Y-m-d H:i:s');
Upvotes: 1