mktime

Discussion in 'PHP' started by Weirfire, Dec 5, 2006.

  1. #1
    Why does

    date('d',mktime(0,0,0,0,0,0,0));

    give 31?
     
    Weirfire, Dec 5, 2006 IP
  2. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #2
    well it returns blank for me ;)

    anyway, note that for mktime "Date with year, month and day equal to zero is considered illegal"
     
    daboss, Dec 5, 2006 IP
    Weirfire likes this.
  3. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Apparently it returns -1 in versions of PHP previous to 5.1 so perhaps you are using the most recent version of PHP

    I'm trying to do a calculation to find out how many days are between 2 different dates and it works up until there are no more days left because my mktime function is of course trying to work out mktime(0,0,0,0,0,0);

    Thanks for your pointers. :)
     
    Weirfire, Dec 5, 2006 IP
  4. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yes, i'm using the latest version of php ;) always like to use the latest tools...

    for days difference, try this ;)


    $days = (strtotime($date1) - strtotime(date($date2))) / (60 * 60 * 24);
    print $days;
    Code (markup):
     
    daboss, Dec 5, 2006 IP
  5. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Thanks! :)
     
    Weirfire, Dec 5, 2006 IP