Bug #16536 Updated: Give me inconsisten results
| From: | hholzgra@php.net | Date: | Thu, 11 Apr 2002 21:39:57 +0000 |
| Subject: | Bug #16536 Updated: Give me inconsisten results | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-4701@lists.php.net to get a copy of this message | ||
ID: 16536
Updated by: hholzgra@php.net
Reported By: james@jimijon.com
-Status: Closed
+Status: Bogus
Bug Type: Date/time related
Operating System: mac os x
PHP Version: 4.1.2
New Comment:
Question one:
When does Daylight Saving Time switch happen
in your country aka. in whatever is configured
on your system?
Question two:
have you at least *tried* mktime(12,0,0,...
to have your calculations noon-based instead
of midnight based?
Previous Comments:
------------------------------------------------------------------------
[2002-04-11 16:42:06] derick@php.net
ya ya, lets keep it closed now.
------------------------------------------------------------------------
[2002-04-11 15:21:09] james@jimijon.com
OK - my apologies, I have wrapped up into one posting both a bug and a
support issue. I will post on the support area, but, I do believe this
is a bug.
------------------------------------------------------------------------
[2002-04-11 14:34:58] hholzgra@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php
------------------------------------------------------------------------
[2002-04-11 14:28:48] james@jimijon.com
$today_var = getdate();
$today_sec =
mktime(0,0,0,date("m"),date("d"),date("Y"),1);
$offset = ($today_var['wday']-0) * 86400 ;
$first_day = $today_sec - $offset;
$this_week_first_date = date("ymd",
$first_day);
$path=$this_week_first_date;
Still gives the wrong result.. Doesn't anybody have a reliable piece of
code to Get the Sunday of the current week, this week it should be the
7th not the 6th!
Now this week however this code works:
date("ymd",
mktime(0,0,0,$mnth,$dy-date("w",mktime(0,0,0,$mnth,$dy,$yr)),$yr))
What gives? A real piece of code that works reliably still needed for
me and for sure everybody.
------------------------------------------------------------------------
[2002-04-11 12:59:47] hholzgra@php.net
Guess it worked last week only due to the daylight saving switch which
compensated an off-by-one error in your code.
*Every* piece of code that uses mktime(0,0,0,...) and
addition or subtraction of multiples of 86400 has to
check for daylight saving time switches or use the optional 7th
parameter to mktime() to be correct
this database is full of user bugs related to this issue
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/16536
--
Edit this bug report at http://bugs.php.net/?id=16536&edit=1