Windows Specific Error? (mktime)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Windows Specific Error? (mktime)

Post by Nay »

My function for drop downs for dates that are taken from mysql:

Code: Select all

function dropdown($value, $section, $name) {

   $days = range(0, 31);

   $months = array("zero", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

   $now = getDate();
   $year = $now['year'];
   $year = $year - 13;
   $last = $year - 20;
   $last = mktime(12, 0, 0, 1, 1, $last);
   $last = date("Y", $last);
   $years = range($last, $year);

   $genders = array("something", "Male", "Female");

   $return = null;

   For($i = 1 ; $i < count(${$section}); $i++):
      If(${$section}[$i] == $value):
         $return .= <<< SEL

<option selected="selected" value="$i">{${$section}[$i]}</option>
SEL;
      Else:
         $return .= <<< OPT

<option value="$i">{${$section}[$i]}</option>
OPT;
      EndIf;
   EndFor;

   $return = <<< RET
<select name="$name">$return
</select>
RET;

   return $return;

}
It works fine but I'm testing this on my localhost windows box - but yet to have try it on my linux server. The problem is that if I decrease the year anyless than 20 ($last = $year - 20) I get this:

Warning: mktime(): Windows does not support negative values for this function in c:\appserv\www\nlogger\includes\functions.php on line 211

Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in c:\appserv\www\nlogger\includes\functions.php on line 212

Warning: mktime(): Windows does not support negative values for this function in c:\appserv\www\nlogger\includes\functions.php on line 211

Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in c:\appserv\www\nlogger\includes\functions.php on line 212

Warning: mktime(): Windows does not support negative values for this function in c:\appserv\www\nlogger\includes\functions.php on line 211

Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in c:\appserv\www\nlogger\includes\functions.php on line 212

Warning: mktime(): Windows does not support negative values for this function in c:\appserv\www\nlogger\includes\functions.php on line 211

Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in c:\appserv\www\nlogger\includes\functions.php on line 212
And one more thing, why is it looping 3 times? I can't seem to spot that either. Getting back, if it's like this, then no one above the age of 33 can use my script if they were on a windows server?

There's got to be a way, right?

-Nay
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

PHP Manual wrote: Note:
In the Microsoft Windows series of Operating Systems the system libraries implementing this function are broken, so gmdate() does not support negative values for the timestamp. For details see bug reports: » #22620, » #22457, and » #14391.

This problem does not occur in Unix/Linux Operating Systems, as the system libraries behave as expected.

PHP cannot fix broken system libraries. Contact your OS vendor for a fix to this and similar problems.
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

he Knowledge Base (KB) Article You Requested Is Currently Not Available

<_<. So otherwise, I'm going to have the problem on Windows?

*falls*

-Nay
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

http://msdn.microsoft.com/library/en-us ... mktime.asp

You are. Period. It's MS, we all love their OSes.
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Ewww Ewww *contaminated with ASP*....

Anyhow, I rampaged through the date functions of PHP and came up with:

Code: Select all

$year = date("Y");
   $year = $year - 10;
   $last = $year - 60;
   $years = range($last, $year);
   $years = array_reverse($years);
Heh, MS........

Thanks anyway,

-Nay
Post Reply