473,383 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Date interogation: April 4th

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
3 1636
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jim | last post by:
I have been using the javascript below on a web page since last August to show the "Site updated" month only minus a month, which has been very successful, but January is showing a "undefined 2004"...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
8
by: Dennis M. Marks | last post by:
What is the maximum valid date range for the date(yyyy,mm,dd) function. -- Dennis M. Marks http://www.dcs-chico.com/~denmarks/ Replace domain.invalid with dcsi.net -----= Posted via...
38
by: | last post by:
I have a script... ----- <SCRIPT language="JavaScript" type="text/javascript"> <!-- function makeArray() { for (i = 0; i<makeArray.arguments.length; i++) this = makeArray.arguments; } ...
9
by: mistral | last post by:
Need help to remove list of days from date script. Need format "June 07, 2006" <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Get today's current date. var now = new Date();
3
by: jamesDA | last post by:
I have written a simple membership database which prints cards using a report with an expiry date on. The expiry date should be the Date Issued field plus one year and one week. I can add 53 weeks...
4
by: shapper | last post by:
Hello, I have created a GridView on runtime by implementing the ITemplate class. This Gridview displays a list of articles. Each article has a Title, Content and PubDate. I am trying to...
34
by: -Lost | last post by:
I'm REALLY liking this so far. And for those who welcome something a little less cryptic than what the resident date guru offers, here's a chance to try something fairly elegant and definitely...
4
Sandboxer
by: Sandboxer | last post by:
I want to be able to program Access to provide for me, by individual day, what my contract obligations are to my customers. Will Access recognize all the individual days in between a date range...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.