Jump to content


Photo

mktime problems [solved]


  • Please log in to reply
2 replies to this topic

#1 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 12 July 2006 - 11:53 PM

hey guys,

why is this giving me February when it's supposed to give me March.... and is there a workaround?
<?php
$bList = explode ('-',$row['date_birth']);
echo $bList[1]; //outputs 03
$birth_date = date('F', mktime(0, 0, 0, $bList[1], 0, 0));
echo $birth_date; // outputs February.... not March???
?>



#2 micah1701

micah1701
  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 13 July 2006 - 12:15 AM

from the manual:

The last day of any given month can be expressed as the "0" day of the next month, not the -1 day. Both of the following examples will produce the string "The last day in Feb 2000 is: 29".

<?php
$lastday = mktime(0, 0, 0, 3, 0, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
$lastday = mktime(0, 0, 0, 4, -31, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
?>


so change the day of the month to 1 or any number other then 0

$birth_date = date('F', mktime(0, 0, 0, $bList[1], 1, 0));

"Confidence in the face of risk."

#3 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 13 July 2006 - 03:41 AM

thanks missed that part!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users