Jump to content

[SOLVED] advice on how to format dates in a database...


Dragen

Recommended Posts

Hi,

what is the best or easiest format for storing dates in a mysql database? I'm wanting to store a lot of things with a date value and want it to be as easy as possible to read the date from it... I've had problems with getting dates in the past because of how I stupidly stored them.

I was thinking of simply having

day/month/year
e.g:
22/05/1988

or should I use a unix timestamp?

I really don't know....

Link to comment
Share on other sites

well at the moment my column is called date (for obvious reason..) and is set as date.

I was using dd/mm/yyyy as the format, but changing it to yyyy-mm-dd as changing the column to date seems to require it being formated like this. I'll just have to re-format it using php to display it in dd/mm/yyyy format.

Link to comment
Share on other sites

I've said this few times in these forums - store dates for functionality and not appearance.

 

dd/mm/yyyy format makes it impossible to compare date values ( > or < ) and thus you can't order by that column or select ranges. Nor can you use the many date functions provided in MySql.

Link to comment
Share on other sites

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.