WEB PHP help

Discussion in 'OT Technology' started by projectalpha, Oct 31, 2007.

  1. projectalpha

    projectalpha 二號 Stunna

    Joined:
    Aug 4, 2001
    Messages:
    17,671
    Likes Received:
    0
    Location:
    Bay Area, California
    Anyone know why this would be returning the month of December instead of November? Thanks.

    Code:
    $date = mktime(0,0,0,date('m'), date('d'), date('Y'));
    $day = date('d', $date);
    $month = date('m', $date);
    $year = date('Y', $date);
    echo date('m', mktime(0,0,0,(10 +1),$day,$year));
    
     
    Last edited: Oct 31, 2007
  2. ez4me2c3d

    ez4me2c3d Cold Member

    Joined:
    Sep 19, 2003
    Messages:
    1,836
    Likes Received:
    0
    Location:
    Minneapolis, MN
    I haven't looked into it, but one hangup noobies make is that:
    0 = January and 11 = December (Not 1 = January and 12 = December)
     
  3. ez4me2c3d

    ez4me2c3d Cold Member

    Joined:
    Sep 19, 2003
    Messages:
    1,836
    Likes Received:
    0
    Location:
    Minneapolis, MN
    So i looked into it

    $day = today's current day (which happens to be 31)
    $year = 2007

    mktime(0,0,0,11,$day,$year) = 00:00:00 on November 31, 2007 Right?

    When has there ever been a 31st of November? So the function goes to the next month. 12.


    It's funny, had you tested this yesterday or tomorrow, it would have worked fine, then later down the road your script would have broken without warning. Lucky you.
     
  4. projectalpha

    projectalpha 二號 Stunna

    Joined:
    Aug 4, 2001
    Messages:
    17,671
    Likes Received:
    0
    Location:
    Bay Area, California
    Haha, thanks for the help!
     
  5. ez4me2c3d

    ez4me2c3d Cold Member

    Joined:
    Sep 19, 2003
    Messages:
    1,836
    Likes Received:
    0
    Location:
    Minneapolis, MN
  6. LEGbEND

    LEGbEND .

    Joined:
    Jun 26, 2001
    Messages:
    23,269
    Likes Received:
    5
    Location:
    Shitcago
    by default, the date() function will display the current date/time, if that's all you're going for..
     

Share This Page