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.

 

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.

Link to comment
Share on other sites

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);

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.