FBwall
FBwall

Reputation: 1653

SQL-PHP datetime

I'm integrating an RSS feed unto my website and i need to create a table:

CREATE TABLE `stories` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `description` text NOT NULL,
  `when` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`id`)
)

i know how to insert id, title, description but i do not know how to insert the time of the post (user submits them). I used the script given here.

mysql_query("insert into stories (title,description) VALUES ('$_POST[title]','$_POST[description]') ");

Upvotes: 0

Views: 1162

Answers (1)

davidethell
davidethell

Reputation: 12018

For when use the date function:

date('Y-m-d h:i:s')

By default the date function uses the current date/time if you don't supply one as the second argument.

Upvotes: 4

Related Questions