calendar year beyond 2038

Discussion in 'PHP' started by mindphp, May 23, 2010.

  1. #1
    I’m trying to generate a simple calendar, at any years (between 2000 and 2100). And date() is limited before 2038.

    Does anyone know a simple replacement for it?
     
    mindphp, May 23, 2010 IP
  2. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    Why would you ever need to go past 2038?
     
    Pudge1, May 23, 2010 IP
  3. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Just wait until PHP Moves to PHP 7 May be you may get that! :)
     
    roopajyothi, May 23, 2010 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    If you're on PHP 5.2+, use a DateTime object.

    <?php
    
    $date = new DateTime('2000-01-01');
    $date->modify('+147 years 8 months 21 days 12 hours 46 minutes 22 seconds');
    echo $date->format('r') . "\n";
    
    ?>
    PHP:
    joebert@frankenstien:~/Desktop$ php -f _.php 
    Fri, 22 Sep 2147 12:46:22 -0500
    Code (markup):
     
    joebert, May 23, 2010 IP
  5. phpSiteMinder

    phpSiteMinder Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That's what they though in the 70's & 80's about the year 2000.

    Or do you believe in the 2012 conspiracy?
     
    phpSiteMinder, May 23, 2010 IP
  6. Trikun3

    Trikun3 Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I'd go with the DateTime object like joebert said.

    date() doesn't go past 2038 because it's dependent on the unix timestamp. On January 19th at 3:14 am, the unix clock (which is kept in binary) will read all 1's, then it will reset to 0's.
     
    Last edited: May 23, 2010
    Trikun3, May 23, 2010 IP