TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-25-2008, 07:30 PM   #1 (permalink)
The Contributor
 
webosb's Avatar
 
Join Date: Nov 2007
Posts: 41
Thanks: 24
webosb is on a distinguished road
Default advice on datetime data type

I need some advice on whether I should save unix timestamps in MySQL or should I create a datetime datatype and store it like YYYY-MM-DD HH:MM:SS

I'm trying to go with the most efficient way possible. Should I have php do the math for me or should I have the mysql query do the math for me. Can anyone shine some light on this?

Thanks
__________________
"Things you can get access to, you should never memorize." -Albert Einstein
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
webosb is offline  
Reply With Quote
Old 07-28-2008, 03:31 AM   #2 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by webosb View Post
I need some advice on whether I should save unix timestamps in MySQL or should I create a datetime datatype and store it like YYYY-MM-DD HH:MM:SS

I'm trying to go with the most efficient way possible. Should I have php do the math for me or should I have the mysql query do the math for me. Can anyone shine some light on this?

Thanks

I always store Unix Timestamps for my dates/times. :) So I think you should too, cause it's much easier, just a long int. :P
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 07-31-2008, 03:01 PM   #3 (permalink)
The Acquainted
 
Join Date: Oct 2007
Posts: 170
Thanks: 18
maZtah is an unknown quantity at this point
Default

I'm just like Orc storing it as a UNIX TIMESTAMP as an int.
maZtah is offline  
Reply With Quote
Old 07-31-2008, 09:11 PM   #4 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

I also prefer to store the timestamp in the database as an int instead of a DATETIME type of field. It's less memory consuming, in the first place, and secondly, you can then format a timestamp how the hell ever you want.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



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

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:53 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design