Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing timestamps in mySQL

I remember I read somewhere that mySQL timestamp data type is used to be updated automatically when the row updates, is this true?

Do I have to store timestamps with timestamp datatype or with bigint for example?

NB: the timestamp that has to be stored is not generated by mySQL, it's a pre-defined value that will be generated with PHP.

Thanks.

like image 788
medk Avatar asked Jun 29 '11 11:06

medk


1 Answers

ok I think this is resolved.

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html

a zero value timestamp looks like this '0000-00-00 00:00:00', so it can't be used to store a unix timestamp like this : 1309347278, so it must be BIGINT.

Thanks.

like image 153
medk Avatar answered Sep 26 '22 06:09

medk