Newbie style date question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi! I was programming a calendar for a website and ran into this:

mktime(0,0,0,3,27,2005); ->returns 1111878000
mktime(0,0,0,3,26,2005); ->returns 1111795200

and then:
date("d.m.y",1111878000); ->returns 26.03.2005
date("d.m.y",1111795200); ->returns 26.03.2005

Is this something one should except? Shouldn't the timestamps be
trusted or am I just confused?

t sami

Re: Newbie style date question

Sami wrote:

Quoted text here. Click to load it

On my machine

 mktime(0,0,0,3,27,2005) returns 1111838400
 mktime(0,0,0,3,26,2005) returns 1111752000

Adding in the hours minutes and seconds for the various numbers to show
where in the day the value thinks it is gives the following:

 // values from my machine
 print date("d.m.y H:i:s",1111838400); // 27.03.05 00:00:00
 print date("d.m.y H:i:s",1111752000); // 26.03.05 00:00:00

 // values from your example
 print date("d.m.y H:i:s",1111878000); // 27.03.05 11:00:00
 print date("d.m.y H:i:s",1111795200); // 26.03.05 12:00:00

Even though they're both out by several hours they are still in the correct
day when I try them. Which OS are you using, and do you have any strange
timezone settings which may affect the times and dates generated? Are you
sure the numbers and being copied across correctly without any

If you just do
 print date("d.m.y H:i:s")
does it give you the current system date and time as expected?

Chris Hope - The Electric Toolbox - /

Re: Newbie style date question

Hi again

The PHP Version is 4.3.2 and its running on Apache/1.3.27 OS being RedHat 9.0.
I double checked the figures etc. and they are as stated in the earlier
message. The system even returns the correct date/time when called upon
date("d.m.y H:i:s")(local time -2 h as the server is somewhere across the sea
).mktime(0,0,0,3,27,2005) still returns the timestamp of 26.03.2005 23:00 ie.
1111878000. I'm not knowingly using any funky settings (timezone etc.) and
can't get my hands on the settings on the server.*** Did some testing again.
Now mktime(0,0,0,3,27,2005) started to return a timestamp of 1111885200 (yours
is 1111838400 for the same date). Server problem perhaps?

t sami

Re: Newbie style date question

*** Sami escribió/wrote (21 Sep 2004 22:48:57 -0700):
Quoted text here. Click to load it


One day has 86400 seconds so there's a 3600 seconds difference (1 hour).

In my machine (Windows XP / PHP 4.3.2) I get 1111878000 and 1111791600
(exactly 1 day of difference).

Weird... Daylight saving issue? Have you tried playing around with 7th

I've also tested it in another machine (Red Hat 9 / PHP 4.2.2) and I've got
the same figures.

-+ Álvaro G. Vicario - Burgos, Spain
+- (la web de humor barnizada para la intemperie)
++ Las dudas informáticas recibidas por correo irán directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions

Re: Newbie style date question

Quoted text here. Click to load it

Hi! Did some testing as you suggested..

First with 1 as the seventh parameter "the time is during daylight savings time"

echo mktime(0,0,0,3,27,2005,1);// gives a stamp -> 1111878000
result---> 1111878000
echo mktime(0,0,0,3,26,2005,1);// gives a stamp -> 1111791600
result---> 1111791600

difference exactly 86400 ( 1 day )

echo date("d.m.y",1111878000);//26.03.2005 d.m.y
result---> 26.03.05 23:0:00
echo date("d.m.y",1111791600);//25.03.2005 d.m.y
result---> 25.03.05 23:0:00

....not correct.
0 as the seventh parameter "the time is not during daylight savings time"

echo mktime(0,0,0,3,27,2005,0);// gives a stamp -> 1111881600
result---> 1111881600
echo mktime(0,0,0,3,26,2005,0);// gives a stamp -> 1111795200
result---> 1111795200

exactly 86400 ( 1 day )

echo date("d.m.y",1111881600);// d.m.y
result---> 27.03.05 00:0:00
echo date("d.m.y",1111795200);// d.m.y
result---> 26.03.05 00:0:00

the 0 seems to do the trick... I still have to figure out why the anomaly
happens only with 27.03.2005. The functions work otherwise perfectly (sic).

t sami

Re: Newbie style date question (Sami) wrote:
Quoted text here. Click to load it

The answer is pretty obvious.  Summer time in Europe starts on 27.03.2005,
so 26.03.2005 will be only 23 hours long in your time zone.
- Tim Roberts,
  Providenza & Boekelheide, Inc.

Re: Newbie style date question

Quoted text here. Click to load it

If 2005/03/26 has only 23 hours then 2005/03/26 is the first day in
summertime, having 00:00 to 02:00 and 03:00 to 24:00
Simon Stienen < <
»What you do in this world is a matter of no consequence,
 The question is, what can you make people believe that you have done.«
-- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle

Re: Newbie style date question

Quoted text here. Click to load it
Thanks for all. Guess if I'm feeling silly now. I better buy a calendar.
t sami

Site Timeline