clankill3r
clankill3r

Reputation: 9583

insert either pubdate or timestamp into database

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')";

enter image description here

Is my database set up correct?

Upvotes: 1

Views: 134

Answers (1)

John Conde
John Conde

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

Related Questions