php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #346 mktime() on NT isn't working very well
Submitted: 1998-05-05 06:47 UTC Modified: 1998-05-05 12:11 UTC
From: rasmus at lerdorf dot on dot ca Assigned: rasmus (profile)
Status: Closed Package: Misbehaving function
PHP Version: 3.0 Release Candidate 4 OS: NT4
Private report: No CVE-ID: None
 [1998-05-05 06:47 UTC] rasmus at lerdorf dot on dot ca
Try this on NT: <?echo mktime(0,0,0,1,1,1970)?>

I am getting "-1" returned here.

I think Microsoft's version of mktime() is not treating
the tm_isdst component correctly.  According to the Unix
man page for mktime it should behave like this:

     If tm_isdst is positive, the original values are assumed  to
     be  in  the  alternate  timezone.   If it turns out that the
     alternate timezone is not valid for  the  computed  calendar
     time, then the components are adjusted to the main timezone.
     Likewise, if tm_isdst  is  zero,  the  original  values  are
     assumed  to be in the main timezone and are converted to the
     alternate timezone if the main timezone is  not  valid.   If
     tm_isdst is negative, the correct timezone is determined and
     the components are not adjusted.

On Windows it looks like we might have to set tm_isdst to 0
to get the same effect.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-05-05 12:11 UTC] rasmus
returns 18000 on my winnt4 server.  I did do a futz of a code change just to make it look like all of M$'s samples to see if that would change anything, didn't of course.  I'm wondering if it is a problem with non-us versions of windows?

Ok, I figured it out.  mktime() doesn't handle dates before
0:0:0 1/1/1970.  When I feed it 0,0,0,1,1,1970 because I am
in Denmark which is one hour east of GMT, it translates 
into a GMT of 23:0:0 1/31/1969 and hence it returns -1 to 
indicate an illegal date.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC