Jump to content

Recommended Posts

I prefer to go with this:

 

YYYY-MM-DD HH:MM:SS

 

As two digit years can be easily confused with months and or confused with milleniums.

 

Timestamps I do not care for as they have a limit of something like 1969 - 2032. So they do not work for birthdates and other historical / furturistic dates.

It's pretty much useless for DOBs or other historic events. It works pretty well for... well timestamping (i.e. recording when events in your application happen). Remember that MySQL's DATETIME takes 8 bytes, while TIMESTAMP is only 4 bytes. DATE however is only 3 bytes (that's for MyISAM, but I suspect it's quite similar for InnoDB)

 

http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

I'm going to play devil's advocate and vote for the Unix timestamp, at least that value is constant(ly incrementing) whereas a formatted string like the one in the OP leaves plenty of room for errors: of the timezone variety, and lack of range (YY).

I'm going to play devil's advocate and vote for the Unix timestamp, at least that value is constant(ly incrementing) whereas a formatted string like the one in the OP leaves plenty of room for errors: of the timezone variety, and lack of range (YY).

 

That's why it (UNIX time)'s so good for timestamping :P

premiso and salathe both have good ideas. I tend to use the YYYY-MM-DD HH:MM:SS format for compatibility with MySQL, but it could also be a good idea to take note of the UNIX timestamp as a backup, or unique identifier. On a high-traffic website it's possible to have more than one transaction occur within the same second, but it's unlikely you'll ever get two identical UNIX timestamps.

On a high-traffic website it's possible to have more than one transaction occur within the same second, but it's unlikely you'll ever get two identical UNIX timestamps.

 

Actually, if transactions happen within one second there is a very high probability they'll get same timestamp. After all it's number of SECONDS since Epoch.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.