Jump to content

mktime problems [solved]


digitalgod

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]

Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.