NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Best way to store timestamp

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 01-10-2007, 10:44 AM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes

Best way to store timestamp


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
unknowngiver is offline  
Old 01-10-2007, 11:01 AM   #2 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




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.
beaver6813 is offline  
Old 01-10-2007, 11:06 AM THREAD STARTER               #3 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
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?
unknowngiver is offline  
Old 01-10-2007, 11:09 AM   #4 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




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
beaver6813 is offline  
Old 01-10-2007, 11:55 AM   #5 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
TwistMyArm is on a distinguished road
 



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.
TwistMyArm is offline  
Old 01-10-2007, 12:07 PM   #6 (permalink)
NamePros Regular
 
baxter's Avatar
Join Date: Apr 2006
Posts: 363
baxter is just really nicebaxter is just really nicebaxter is just really nicebaxter is just really nice
 


Ethan Allen Fund Save The Children
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.
__________________
Canadian Domain Registrar Ready.ca
baxter is offline  
Old 01-10-2007, 04:09 PM THREAD STARTER               #7 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
aight thanks i will go with time(); thanks
unknowngiver is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:37 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger