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....

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.