insert current timestamp into mysql with php?

mysql, php, timestamp

Solution

Use MySQL's `UNIX_TIMESTAMP()` function to get the current epoch time:

INSERT INTO mytable SET tstamp = UNIX_TIMESTAMP();

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

Problem

This is driving me crazy. I've searched it on interent but can't get to a conclusion. I have a date field in my database. Which I'm retrieving values with date function just fine. Problem is I did it some time ago, and I don't remember how I inserted those values into that field. it's an integer value (according to what I read, the number of seconds since jan 1st 1970, for example 1338949763. but when I try inserting stuff, like using `INSERT INTO entries (date) VALUES (NOW())` . The `NOW` thing will store a formatted date, like `2012-04-12 23:09:54`. I don't want that. I want to store the integer value. how do I do that?

Original source