New to databases - datetime

I am a little stumped by date functions in php. All I want to do is take the current date and time and store this in a table (in a datetime field).

I have tried using the getdate() function and then just passing this into a table via an insert. But it does not work.

How could I do this?

MySQL has an inbuilt function to handle this.


mysql_query("INSERT INTO mytable(datefield) VALUES ([B]NOW()[/B])");

but it is better to use CURRENT_TIMESTAMP instead of NOW()

:slight_smile:

Manual says they’re the same, but i defer to you.

one of them is standard sql and should work in many different databases, which means less headaches if you should ever want to port your application code to some other database

as i always say, if mysql supports two identical functions, and one of them is standard sql and the other one is proprietary to mysql, use the standard one

:slight_smile: