tags:

views:

46

answers:

2

Well, found out that I built a relatively large program built on top of DateTime, only to find most of what I used there got added in PHP 5.3. The server I have to deploy to does not run 5.3. (And it's a Ubuntu Hardy (8.04) box which doesn't have a 5.3 package in the main repo, and I'm not allowed to install anything not in the main repos on that box...)

  1. Is there some way to get a copy of the date and time function reference as was current for 5.2.4?
  2. What is the best way to pass dates around? ints containing unix epoch times?
+1  A: 

When passing data around, I prefer to use unix timestamps. If you have a different representation, you can use strtotime() to convert it.

There are a few functions that come in handy when working with dates & times. it looks like a lot of what is done w/ the DateTime object can be handled with some combinations of these methods:

also, just a clarification on your terminology, the unix epoch is the moment all unix timestamps count from, which is midnight, Dec 31, 1969.

GSto
What type should I generally use to pass dates and times around though?
Billy ONeal
@Billy, realized I didn't read the question carefully, updated my answer.
GSto
@GSto: It was kind of poorly written. I've edited it a bit :) Thanks :)
Billy ONeal
A: 

Always using unix timestamps as int for date/time no matter of mysql version.

JohnZ
What does MySQL have to do with my question? And if you're in PHP 5.3, why not use the DateTime object?
Billy ONeal
Oops.. sorry, I wasn't slept for more then a day when I read your question and now I see that I read Mysql instead PHP :))
JohnZ
But anyway:), I still prefer unix timestamps for working with date/time, and just using date() for displaying it when needed.
JohnZ
@JohnZ: DateTime uses unix timestamps internally anyway. It just additionally hangs methods off the value.
Billy ONeal