Insert current timestamp in mysql with php?

It drives me crazy. I was looking for him in between, but I cannot come to a conclusion.

I have a date field in my database. Which I get the values ​​with the date function is just fine.

The problem is that I did this a while ago, and I don’t remember how I inserted these values ​​into this field. this is an integer value (in accordance with what I read, the number of seconds since January 1, 1970, for example 1338949763. but when I try to insert material, for example using INSERT INTO entries (date) VALUES (NOW()). The thing NOWwill store a formatted date, for example 2012-04-12 23:09:54I do not want this. I want to save integer value. How to do this?

+5
source share
5 answers

MySQL UNIX_TIMESTAMP(), :

INSERT INTO mytable SET tstamp = UNIX_TIMESTAMP();

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp

+18

- "INSERT INTO entries (date) VALUES ('".time()."')"

+1

:

getdate()

NOW()
0

if u wants to insert a timestamp, that is, some integer value in the mysql field; field type should be "timestamp" and not "datetime", then I hope your integer value will be accepted by DB

0
source

you can try this for insert

INSERT into Table_name (colunm_name) VALUES ('".time()."');
0
source

All Articles