Jump to content

what will be the best way to store date?


phpmady

Recommended Posts

Your choices should be based on knowledge/information not preference! If your row contains ONE timestamp it will update this one on each UPDATE regardless if you specified a value for it, the same applies for the first TIMESTAMP column if you have multiple such fields.

Your choices should be based on knowledge/information not preference! If your row contains ONE timestamp it will update this one on each UPDATE regardless if you specified a value for it, the same applies for the first TIMESTAMP column if you have multiple such fields.

 

This is partially true.  You can control this with DEFAULT and ON UPDATE.  This automation is a feature of TIMESTAMP if you want to use it.  The major difference is DATETIME is 1000-01-01 00:00:00' to '9999-12-31 23:59:59' whereas TIMESTAMP is only '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07.

I use the date() function a lot. Easy to work with the raw number.

 

Make a db input of 15 int, then set the date/time with Linux Timestamp.  Set something like $now = date(); then use $now in the sql insert.  This way all db times are set at that standard, and whenever retrieving that data, you can manipulate or use that in whatever way you want.  Really helps for finding the difference between two times, and can be presented however you want using something like

 

date("F j, Y", $dateEarned);

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.