#1
  1. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,378
    Rep Power
    594

    Dealing with 'strtotime' and Dates That Exceed its Max


    I am processing dates with 'strtotime' some of which are far into the future exceeding its max (which really isn't all that far way compared to paying off the national debt). I can parse the date myself which defeats the convenience of using 'strtotime' but perhaps where is some other method that has not occurred to me. It appears that 'strtotime' treats a bad date format exactly the same as a valid format that exceeds the max. Is it correct that both return false and there is no way to distinguish the difference?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    why do you even use strtotime() with all its limitations? I'd use the DateTime class.
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,850
    Rep Power
    6351
    The datetime class may help you better, or installing a 64-bit version of PHP on a 64-bit system, which should allow you to process more dates past the 32-bit end-of-time.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,378
    Rep Power
    594
    Thanks, I wasn't aware of datetime class. I'll take a look. Sadly I cannot run 64-bit PHP on a 32 bit machine. This is a shoestring operation.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,850
    Rep Power
    6351
    If it's a shoestring operation with a PHP version prior to 5.3, it may not have DateTime.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    If it's a shoestring operation with a PHP version prior to 5.3, it may not have DateTime.
    And in that case you're probably SOL and will need to parse the date yourself. You won't be able to store it or manipulate it as an integer in PHP though, because on 32-bit PHP integers are only 32 bits.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,378
    Rep Power
    594
    I keep it up to date. Its 5.3.3.

    Yes, I am now parsing it myself for the time being. I need to ready up on the DateTime Class.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo