0

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..!!

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by sudeepjd
0

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.

Edited by paulrajj: n/a

0

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

0

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..

0

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.

Edited by sudeepjd: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.