Jump to content

Archived

This topic is now archived and is closed to further replies.

digitalgod

mktime problems [solved]

Recommended Posts

hey guys,

why is this giving me February when it's supposed to give me March.... and is there a workaround?
[code]
<?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???
?>[/code]

Share this post


Link to post
Share on other sites
from the manual:

[quote]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);
?>

[/quote]

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

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.