Forum Moderators: coopster
Here's my code:
$date = unixtojd(mktime(0, 0, 0, $month, $day, $year));
$datearray = cal_from_jd($date, CAL_GREGORIAN);
print_r($datearray);
Here's the output when $month=3, $day=11, and $year=2007:
Array
(
[date] => 3/11/2007
[month] => 3
[day] => 11
[year] => 2007
[dow] => 0
[abbrevdayname] => Sun
[dayname] => Sunday
[abbrevmonth] => Mar
[monthname] => March
)
Here's the output when $month=3, $day=12, and $year=2007:
Array
(
[date] => 3/11/2007
[month] => 3
[day] => 11
[year] => 2007
[dow] => 0
[abbrevdayname] => Sun
[dayname] => Sunday
[abbrevmonth] => Mar
[monthname] => March
)
Here's the output when $month=3, $day=13, and $year=2007:
Array
(
[date] => 3/12/2007
[month] => 3
[day] => 12
[year] => 2007
[dow] => 1
[abbrevdayname] => Mon
[dayname] => Monday
[abbrevmonth] => Mar
[monthname] => March
)
Is there something I'm missing?
It's saying that March 11 occurs 86,400 seconds later than March 10, which is correct, but that March 12 occurs only 82,400 seconds after March 11.
In North America, Daylight Savings Time in 2007 starts on March 11th. This may well have a bearing on the problem. :) Shouldn't shift things by a day, though, only by an hour.
Thanks!
On August 8, 2005, President George W. Bush signed the Energy Policy Act of 2005. This Act changed the time change dates for Daylight Saving Time in the U.S. Beginning in 2007, DST will begin on the second Sunday in March and end the first Sunday in November.
Well okay, the unixtojd() function isn't figuring DST properly.
$now = mktime(0, 0, 0, 3, 11, 2007);
$date = unixtojd($now);
print "Mar 11 Julian Date = $date\n";
$now = mktime(0, 0, 0, 3, 12, 2007);
$date = unixtojd($now);
print "Mar 12 Julian Date = $date\n";
Mar 11 Julian Date = 2454171
Mar 12 Julian Date = 2454171
I'd find a way to do it without Julian dates.
Julian Days start at noon, not at midnight. If you shift to
13:00 you'll see that it works fine.
I'll try to find the official documentation on this :)
[edit]
I guess this [en.wikipedia.org] will do.
[/edit]