To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Code Critique

Code Critique Having someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.

View Poll Results: Storing time values - how?
UNIX Timestamp 9 42.86%
MySQL Date Field 9 42.86%
1.21 Gigawatts? 3 14.29%
Voters: 21. You may not vote on this poll

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 4.00 average. Display Modes
Old 01-27-2004, 07:47 AM   #1
sid
<? define(VEGAN, true);?>
 
sid's Avatar
 
Join Date: Aug 2002
Location: linz/austria (mn/usa)
Posts: 705
UNIX Timestamp vs. MySQL Date Format

how do you prefer to store dates in a database?

i personally ONLY use unix timestamps - it just proved to be the most flexible way to operate with dates. yep - true - i compromise by losing the mysql date functions, but oh well ;-)
__________________
Fatal error: Call to undefined function: signature() in /home/virtual/var/www/html/showthread.php on line 87 <?PHPBuilder Profile?>
X 666 X
sid is offline   Reply With Quote
Old 01-27-2004, 01:14 PM   #2
rgermain
Senior Member
 
rgermain's Avatar
 
Join Date: Mar 2003
Location: Detroit Lakes, MN
Posts: 229
I found that I prefer the Unix Timestamp also. To me just seems easier to use. That might just be me though!
rgermain is offline   Reply With Quote
Old 01-27-2004, 02:34 PM   #3
Moonglobe
Better fan than rebelo!
 
Moonglobe's Avatar
 
Join Date: Apr 2003
Location: brain://localhost:left-side
Posts: 2,381
i just store dates as type date and then do SELECT UNIX_TIMESTAMP(col).... lets me use all the date functions and still get a timestamp
__________________
there's no place i can be, since i found serenity.
Moonglobe is offline   Reply With Quote
Old 01-27-2004, 10:55 PM   #4
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,122
MySQL timestamps give greater dynamic range (if you need, e.g., dates in the 16th or 25th Centuries); but you're asking for hassles if you don't use MySQL's own date/time functions to work with them before returning query results, and they are inaccurate pre Gregorian calendar. Unix timestamps fail for dates after January 2038, but that's a platform-dependent limit.

__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

Last edited by Weedpacket; 02-05-2004 at 05:12 PM.
Weedpacket is offline   Reply With Quote
Old 02-17-2004, 08:57 PM   #5
Merve
black sheep with red wool
 
Merve's Avatar
 
Join Date: Jul 2003
Location: North of the 49th parallel
Posts: 2,579
I voted for 1.21 gigawatts because i would use whatever one is best for the situation.
__________________
"A proof is a proof. What kind of a proof? It's a proof. A proof is a proof. And when you have a good proof, it's because it's proven." -- Jean Chrétien

The Three C's
Merve is offline   Reply With Quote
Old 02-17-2004, 09:11 PM   #6
ahundiak
Bright Member
 
ahundiak's Avatar
 
Join Date: Aug 2002
Posts: 1,608
You left out using a char field and storing time stamps as YYYYMMDDHHMMSS

Platform independent, database independent, human readable, nice big date range though I admit it you go back a few centuries then things can more complicated.
ahundiak is offline   Reply With Quote
Old 02-18-2004, 11:24 AM   #7
drawmack
Computers can do that?
 
drawmack's Avatar
 
Join Date: Apr 2003
Location: Pocono Mtns PA
Posts: 3,268
depends on my mood that day, since I have classes built for working with both it doens't make a whole lot of difference from a programming standpoint.
drawmack is offline   Reply With Quote
Old 02-18-2004, 07:50 PM   #8
jebster
Some clever title
 
Join Date: Sep 2002
Location: At home...
Posts: 649
I usually use MySQL date fomat. So where's the code I'm suppose to critique?
__________________
Jebster
jebster is offline   Reply With Quote
Old 02-18-2004, 07:57 PM   #9
Moonglobe
Better fan than rebelo!
 
Moonglobe's Avatar
 
Join Date: Apr 2003
Location: brain://localhost:left-side
Posts: 2,381
i suppose this is more of an "idea critique"
__________________
there's no place i can be, since i found serenity.
Moonglobe is offline   Reply With Quote
Old 02-18-2004, 08:21 PM   #10
jebster
Some clever title
 
Join Date: Sep 2002
Location: At home...
Posts: 649
Guess I misunderstood BuzzLY's post
Quote:
From Rule Breakers please heed...
This forum is for complete, working code only.
__________________
Jebster
jebster is offline   Reply With Quote
Old 02-19-2004, 12:18 AM   #11
Moonglobe
Better fan than rebelo!
 
Moonglobe's Avatar
 
Join Date: Apr 2003
Location: brain://localhost:left-side
Posts: 2,381
language (spoken) is a code in a sense.... and it certainly works, most of the time
__________________
there's no place i can be, since i found serenity.
Moonglobe is offline   Reply With Quote
Old 02-20-2004, 01:01 AM   #12
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,122
Oh well, if we're going to critique alternate date formats, there's also the Julian Day format. Astronomers have used it for decades. Date/times are specified in days and fractions of a day since midday, 1st January 4713BC. (Julian calendar; i.e., no Gregorian correction - which is where PHP's calendar implementation seems to fall down. I'm checking this.)
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Weedpacket is offline   Reply With Quote
Old 02-20-2004, 04:52 AM   #13
jebster
Some clever title
 
Join Date: Sep 2002
Location: At home...
Posts: 649
Quote:
Originally posted by Weedpacket
Oh well, if we're going to critique alternate date formats, there's also the Julian Day format. Astronomers have used it for decades. Date/times are specified in days and fractions of a day since midday, 1st January 4713BC. (Julian calendar; i.e., no Gregorian correction - which is where PHP's calendar implementation seems to fall down. I'm checking this.)
Do you just know all these things or do you look up the details when posting it? Cause you must have one wicked bad memory! I can't even remember to eat breakfast in the morning or go to sleep at night!

**EDIT**
Oops, apparently I can't even remember how to spell!
__________________
Jebster

Last edited by jebster; 02-20-2004 at 06:36 AM.
jebster is offline   Reply With Quote
Old 02-20-2004, 06:13 AM   #14
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,122
Quote:
Originally posted by jebster
Do you just know all these things or do you look up the details when posting it? Cause you must have one wicked bad memory! I can't even remeber to eat breakfast in the morning or go to sleep at night!
I do it by not bothering to remember useless information, like when to do the laundry, check the tyre pressure on my car, or what I'm supposed to be buying for dinner.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Weedpacket is offline   Reply With Quote
Old 02-20-2004, 06:44 AM   #15
jebster
Some clever title
 
Join Date: Sep 2002
Location: At home...
Posts: 649
Quote:
Originally posted by Weedpacket
I do it by not bothering to remember useless information, like when to do the laundry, check the tyre pressure on my car, or what I'm supposed to be buying for dinner.
Buy stuff for dinner? I just stock up on cans of ravioli, tomato soup, chicken noodle soup, and Kirkland Ice tea, then I'm good for months
__________________
Jebster
jebster is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting 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 Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 03:17 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.