By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,047 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,047 IT Pros & Developers. It's quick & easy.

Date interogation: April 4th

P: n/a
Hello all,

One of our PHP program bugged recently. I've reduced the problem to this:
April 4th!

Anybody can tell me if I'm doing something wrong? Why April 4th is not
printing but replaced by April 3rd? I'm using PHP 4.3.5

Yannick

--------- PHP file ---------
<html>
<head>
<title>Test</title>
</head>
<body>
<?
// First group
// This should print the three dates formated as requested: Y-m-d
print date("Y-m-d", mktime(0,0,0, 4, 3, 2004))."<br>"; // April 3rd 2004
print date("Y-m-d", mktime(0,0,0, 4, 4, 2004))."<br>"; // April 3rd 2004
print date("Y-m-d", mktime(0,0,0, 4, 5, 2004))."<br>"; // April 3rd 2004

// This should and do print the mktime corresponding to the numbers in the
third group of three
print mktime(0,0,0, 4, 3, 2004)."<br>"; // April 3rd 2004
print mktime(0,0,0, 4, 4, 2004)."<br>"; // April 4th 2004
print mktime(0,0,0, 4, 5, 2004)."<br><br>"; // April 5th 2004

// This too should print the three dates formated as requested: Y-m-d
print date("Y-m-d", 1080968400)."<br>"; // April 3rd 2004
print date("Y-m-d", 1081051200)."<br>"; // April 4th 2004
print date("Y-m-d", 1081137600)."<br><br>"; // April 5th 2004
?>
</body>
</html>
--------- PHP file end ---------

--------- Output - IE5.5 ---------
2004-04-03
2004-04-03
2004-04-05

1080968400
1081051200
1081137600

2004-04-03
2004-04-03
2004-04-05
--------- Output end ---------


Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Yannick,

On Wed, 14 Apr 2004 17:33:13 -0400, "Yannick Turgeon"
<no****@nowhere.com> wrote:
Hello all,

One of our PHP program bugged recently. I've reduced the problem to this:
April 4th!

Anybody can tell me if I'm doing something wrong? Why April 4th is not
printing but replaced by April 3rd? I'm using PHP 4.3.5

Have you checked your locale and daylight saving?

HTH, Jochen
Yannick

--------- PHP file ---------
<html>
<head>
<title>Test</title>
</head>
<body>
<?
// First group
// This should print the three dates formated as requested: Y-m-d
print date("Y-m-d", mktime(0,0,0, 4, 3, 2004))."<br>"; // April 3rd 2004
print date("Y-m-d", mktime(0,0,0, 4, 4, 2004))."<br>"; // April 3rd 2004
print date("Y-m-d", mktime(0,0,0, 4, 5, 2004))."<br>"; // April 3rd 2004

// This should and do print the mktime corresponding to the numbers in the
third group of three
print mktime(0,0,0, 4, 3, 2004)."<br>"; // April 3rd 2004
print mktime(0,0,0, 4, 4, 2004)."<br>"; // April 4th 2004
print mktime(0,0,0, 4, 5, 2004)."<br><br>"; // April 5th 2004

// This too should print the three dates formated as requested: Y-m-d
print date("Y-m-d", 1080968400)."<br>"; // April 3rd 2004
print date("Y-m-d", 1081051200)."<br>"; // April 4th 2004
print date("Y-m-d", 1081137600)."<br><br>"; // April 5th 2004
?>
</body>
</html>
--------- PHP file end ---------

--------- Output - IE5.5 ---------
2004-04-03
2004-04-03
2004-04-05

1080968400
1081051200
1081137600

2004-04-03
2004-04-03
2004-04-05
--------- Output end ---------


--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2

P: n/a
On Wed, 14 Apr 2004 17:33:13 -0400, "Yannick Turgeon" <no****@nowhere.com>
wrote:
One of our PHP program bugged recently. I've reduced the problem to this:
April 4th!

Anybody can tell me if I'm doing something wrong? Why April 4th is not
printing but replaced by April 3rd? I'm using PHP 4.3.5

Yannick

--------- PHP file ---------
<html>
<head>
<title>Test</title>
</head>
<body>
<?
// First group
// This should print the three dates formated as requested: Y-m-d
print date("Y-m-d", mktime(0,0,0, 4, 3, 2004))."<br>"; // April 3rd 2004
print date("Y-m-d", mktime(0,0,0, 4, 4, 2004))."<br>"; // April 3rd 2004
print date("Y-m-d", mktime(0,0,0, 4, 5, 2004))."<br>"; // April 3rd 2004

// This should and do print the mktime corresponding to the numbers in the
third group of three
print mktime(0,0,0, 4, 3, 2004)."<br>"; // April 3rd 2004
print mktime(0,0,0, 4, 4, 2004)."<br>"; // April 4th 2004
print mktime(0,0,0, 4, 5, 2004)."<br><br>"; // April 5th 2004

// This too should print the three dates formated as requested: Y-m-d
print date("Y-m-d", 1080968400)."<br>"; // April 3rd 2004
print date("Y-m-d", 1081051200)."<br>"; // April 4th 2004
print date("Y-m-d", 1081137600)."<br><br>"; // April 5th 2004
?>
</body>
</html>
--------- PHP file end ---------

--------- Output - IE5.5 ---------
2004-04-03
2004-04-03
2004-04-05

1080968400
1081051200
1081137600

2004-04-03
2004-04-03
2004-04-05
--------- Output end ---------


Output on 4.3.5 here is:

2004-04-03
2004-04-04
2004-04-05
1080946800
1081033200
1081119600

2004-04-03
2004-04-04
2004-04-05

Changing the date format to include 'r' shows for your Unix dates:

2004-04-03 Sat, 3 Apr 2004 06:00:00 +0100
2004-04-04 Sun, 4 Apr 2004 05:00:00 +0100
2004-04-05 Mon, 5 Apr 2004 05:00:00 +0100

Is this a time zone issue? Doesn't Daylight Savings Time kick in on the first
Sunday in April in the US? So that would be the 4th.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #3

P: n/a
Hi guys,

you're rigth. It's related to dayligth saving. I just added 59 minutes to
the mktime function: same problem. And with 60, no problem.

Thanks for your help.

Yannick

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:74********************************@4ax.com...
On Wed, 14 Apr 2004 17:33:13 -0400, "Yannick Turgeon" <no****@nowhere.com>
wrote:
One of our PHP program bugged recently. I've reduced the problem to this:
April 4th!

Anybody can tell me if I'm doing something wrong? Why April 4th is not
printing but replaced by April 3rd? I'm using PHP 4.3.5

Yannick

--------- PHP file ---------
<html>
<head>
<title>Test</title>
</head>
<body>
<?
// First group
// This should print the three dates formated as requested: Y-m-d
print date("Y-m-d", mktime(0,0,0, 4, 3, 2004))."<br>"; // April 3rd 2004 print date("Y-m-d", mktime(0,0,0, 4, 4, 2004))."<br>"; // April 3rd 2004 print date("Y-m-d", mktime(0,0,0, 4, 5, 2004))."<br>"; // April 3rd 2004
// This should and do print the mktime corresponding to the numbers in thethird group of three
print mktime(0,0,0, 4, 3, 2004)."<br>"; // April 3rd 2004
print mktime(0,0,0, 4, 4, 2004)."<br>"; // April 4th 2004
print mktime(0,0,0, 4, 5, 2004)."<br><br>"; // April 5th 2004

// This too should print the three dates formated as requested: Y-m-d
print date("Y-m-d", 1080968400)."<br>"; // April 3rd 2004
print date("Y-m-d", 1081051200)."<br>"; // April 4th 2004
print date("Y-m-d", 1081137600)."<br><br>"; // April 5th 2004
?>
</body>
</html>
--------- PHP file end ---------

--------- Output - IE5.5 ---------
2004-04-03
2004-04-03
2004-04-05

1080968400
1081051200
1081137600

2004-04-03
2004-04-03
2004-04-05
--------- Output end ---------
Output on 4.3.5 here is:

2004-04-03
2004-04-04
2004-04-05
1080946800
1081033200
1081119600

2004-04-03
2004-04-04
2004-04-05

Changing the date format to include 'r' shows for your Unix dates:

2004-04-03 Sat, 3 Apr 2004 06:00:00 +0100
2004-04-04 Sun, 4 Apr 2004 05:00:00 +0100
2004-04-05 Mon, 5 Apr 2004 05:00:00 +0100

Is this a time zone issue? Doesn't Daylight Savings Time kick in on the

first Sunday in April in the US? So that would be the 4th.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.