hi guys,
pls help me out..
how can i insert the current date into mysql data base through php ??
n pls tell how to retrieve also..
its urgetnt..!!

Hi,

Using php you can accomplish this using date() function like below,

$date = date("Y-m-d H:i:s");
$query = mysql_query("insert into tablename (`dated`) values ('".$date."')");

Another way using mysql function now(),

$query = mysql_query("insert into tablename (`dated`) values (now())");

Provide some info about your table structure, it could help to find the datatype info of date column.

Member Avatar

Aww. This is a gimme post. Should have sent him to Coventry.

Hi,

Using php you can accomplish this using date() function like below,

$date = date("Y-m-d H:i:s");
$query = mysql_query("insert into tablename (`dated`) values ('".$date."')");

Another way using mysql function now(),

$query = mysql_query("insert into tablename (`dated`) values (now())");

Provide some info about your table structure, it could help to find the datatype info of date column.

hey,
thank u very much...!!
it worked..

Isn't it list way easier to use a TIMESTAMP Datatype and then use mySQL's ON UPDATE CURRENT_TIMESTAMP clause.

I'm pretty sure this could have been got from google.