Jump to content

How to store date in mysql database


PigsHidePies

Recommended Posts

When I deal with dates I prefer to use a unix timestamp (number secounds since Jan 1st 1970), I grab the timestamp using the time() function, then use an INT value and give it a max length of 20 or so.

When I retrieve the date I use the date function to convert the timestamp into a readable date, using the secound parameter of the date functions.
[code=php:0]date("D-m-y", $row['timestamp']);[/code]


If you wnat to use the date function, then you'll wenat to use a VARCHAR field set to 255 chars.

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.