I always use unix timestamps for everything, but am wondering if there is a better way.
What do you use to store timestamps and why?
UNIX Timestamp 32-bit problem seems to be pretty annoying for users who enter future dates in 2038+.
Either use the DATETIME sequence for MySQL, or store your dates as BIGINT(8) unsigned (max: 18 quintillion) or FLOAT so that you can enter large numbers. Then you cannot use for example PHP's date() function because it only allows integers as parameter (limited by 32-bit systems).
The solution I found is to use PHP 5.2.0 functions. Here's the DateTime PHP solution.
No need to change UNIX_TIMESTAMP format. As long as you have BIGINT(8) unsigned as your MySQL storage for timestamps. You won't be limited by 32-bit systems anymore.
A timestamp is bascially:
And as a point in time has an endless resolution, the important thing on choosing a timestamp format is: has it enough resolution?
For most applications I had, nanoseconds were enough. So Java Timestamp had the right resolution for me so far.
32 bit Unix timestamps will overflow in a few years (January 2038), so that might be a consideration. I generally use a DATETIME format in SQL, which is YYYY-MM-DD HH:MM:SS with the time as a 24-hour clock. I try to output to files in the same format, just to make my life easier.