Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > storing date & time in mysql

storing date & time in mysql
Thread Tools
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Jun 13, 2004, 12:16 PM
 
what's the preferred method with y'all? which do you find plays best with php:

timestamp or datetime?

examples would be nice with your answers
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Jun 13, 2004, 05:13 PM
 
I always use datetime. one reason is, that sometimes I will browse through the database or manually enter some rows in the database, and a timestamp really does me no good on a date or date/time field.

I guess it would really not matter, because it PHP, you can pretty easily convert from one to the other if needed.

I guess I prefer datetime because like I said, it is human readable.
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Jun 13, 2004, 06:18 PM
 
Originally posted by philzilla:
what's the preferred method with y'all? which do you find plays best with php:

timestamp or datetime?

examples would be nice with your answers
Datetime - it's much easier to read when I'm browsing through records with phpmyadmin!

These days I'm using Smarty more often than not, and it prefers a unix timestamp for its date_format conversion, so I'll always perform an SQL like:

SELECT UNIX_TIMESTAMP(date_created) FROM table

when I'm retrieving, then an

INSERT INTO table (date_created) VALUES (".date('Y-m-d h:i:s',$timestamp)

when I put it back

This way I can also utilise native SQL date functions and they'll perform as expected
Computer thez nohhh...
     
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Jun 14, 2004, 08:52 AM
 
always good to hear other opinions match your own

cheers, guys.
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Mac Elite
Join Date: Jun 2001
Location: Dundee, Scotland
Status: Offline
Reply With Quote
Jun 23, 2004, 07:59 PM
 
Originally posted by philzilla:
always good to hear other opinions match your own

cheers, guys.
Don't use TIMESTAMP as it will change if you modify any other data in that row (unless that's what you want).
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:35 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2