NYCPHP Meetup

NYPHP.org

[nycphp-talk] Date Calculation Error

David Sklar sklar at sklar.com
Fri May 28 10:39:42 EDT 2004


> I've looked at the recipe in the <fawn>justly legendary</fawn> PHP
> Cookbook. It involves converting to Julian day. I came across it
> belatedly, after I'd rolled my own solution that converts the input dates
> to GMT and then does the arithmetic. It appears to work with every case
> I've thrown at it; I've tested the hell out of it. Still I wonder if you
> guys think the strategy is sound.
> 
> One thing I like about my solution is that it doesn't require any
> extensions to be loaded.

Doing all your internal date math with GMT is a good idea. As long as 
you don't use $timestamp += 86400 or $timestamp -=86400 for incrementing 
  or decrementing by 1 day, then you should be OK. strtotime() is pretty 
good about respecting DST changes. Depending on your system, though, 
Julian days handle a wider range of dates than epoch timestamps.

David




More information about the talk mailing list