NameSilo

Best way to store timestamp

Spaceship Spaceship
Watch
Impact
19
Hey
whats the best way to store timestamp in the database?
Right now i have a field called timestamp, which is an int (11) and i get "time()" of the function performed and insert it into the database with the other information, but i am not sure if this is the right way of doing it. Thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
As far as i know that is the best way to store the timestamp, then you can manipulate it anyway you want when retrieving it.
 
0
•••
in the TYPE column [when your adding a field] there is one called "TimeStamp" i just tried that..and if you check the "Timestamp" for the default value..it adds the date in this format :
2007-01-10 12:58:53
is it better?
 
0
•••
No, just go with the PHP timestamp time(). If you're using this timestamp with PHP it is by far the best way to go as you can manipulate that timestamp once you retrieve it to whatever you want. ie. that long number could transform into 02/07/07 or even just into the time 13:21. The PHP timestamp time() is also more flexible and easier to manipulate :) :imho:
 
0
•••
I would suggest using the proper MySQL timestamp but using the MySQL 'conversion' functions of UNIX_TIMESTAMP and FROM_TIMESTAMP. That way you deal with normal timestamps in PHP but by using those functions you can still store in the DB proper MySQL timestamps.
 
0
•••
I've always just used the php function time() and int 11 but I guess its up to your preference I don't believe one has a significant speed/quality over the other.
 
0
•••
aight thanks :) i will go with time(); thanks :D
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back