Page 1 of 1
MySQL Timestamp appears as DateTime
Posted: 12 Nov 2014, 07:14
by Marius
Why in my database, time is of type Timestamp but has no numeric form: 1402008961, but is of the form: 07/25/2014 12:13:45 ?
MySQL Timestamp appears as DateTime
Posted: 12 Nov 2014, 07:24
by MarPlo
Hello
Timestamp in MySQL is different from Unix Timestamp, which as you know is a number of seconds starting from 1970.
Timestamp in MySQL is actually a Date Time stored as: Year-Month-Day Hour: Minute: Seconds, like DateTime format.
The difference between Timestamp and DateTime in MySQL is that the Timestamp format is not affected by the time zone set on the server, and does not support Null value, while DateTime changes the value according to the time zone of the server.
- If you want the Select query to return the Unix Timestamp numeric value, use the UNIX_TIMESTAMP() MySQL function.
Code: Select all
SELECT id, col2, UNIX_TIMESTAMP(col_timestamp) AS col_timestamp FROM table