php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19458 Possible problem with date function?
Submitted: 2002-09-17 16:33 UTC Modified: 2002-09-17 16:35 UTC
From: wleoni75 at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.2.0 OS: SunOS
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wleoni75 at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-09-17 16:33 UTC] wleoni75 at hotmail dot com
Having a problem with date(). I simplified the program I am working on
so you can copy and paste the code and see the problem right away.

I start with the month of october and year of 2002 ($month and $year).

I convert that to the POSIX time ($time) of the the first second of
that month.

Then, I keep adding 24*3600 seconds to that time until the end of the
month.

If you run the program, you will see I get TWO 27/10/2002 -- WHY??

WHY? WHY? WHY?


Here is the code:

================ START CODE =======================

$year = "2002";
$month = "10";

$time = mktime (0,0,0,$month,1,$year);

$last_day_of_the_month = date("t",$time);

echo "Last day of the month ($month/$year):
$last_day_of_the_month<br><br>";

for ($day=1;$day<=$last_day_of_the_month;$day++) {

	$new_time = $time + ($day-1)*24*3600;

	echo date("m/d/Y",$new_time);
	echo " (seconds added to original time: ".(($day-1)*24*3600).")";
	echo "<br>";

}

=================== END CODE =====================

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-17 16:35 UTC] derick@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.

You just discovered Daylight Savings Time! :)

try gmdate() instead

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC