Results 1 to 3 of 3

Thread: Difference in hours (PHP)

  1. #1
    Join Date
    Feb 2012

    Difference in hours (PHP)

    I have searched thru the posts and don't see what I'm looking for.
    I need to determine if Date1 is more than 60 hours from Date2.

    It is for a camp reservation script, so thta if people arrive(Date2) less
    than 60 hours from Date1, I can tell "Too Soon" or if more than 60 hours,
    Appreciate any help I can get.

    This is where I'm at now,
    $diff = time() - "2012-06-29:00:00:01";
    echo time(), "\n";
    echo "\n";
    echo ($diff), "\n" ;
    echo "\n";
    $diff2 = $diff*60*60;
    echo "\n";
    echo ($diff2), "\n" ;

    Tom Rector

  2. #2
    Join Date
    Jan 2004
    I don't have the time to solve this for you simply because every time I have mess around with time I have to relearn it. That being said you should check out
    the mktime()


    look at the user posts that should put you on the right path
    Natdrip :P
    "water go down the hole" - plucky duck

  3. #3
    Join Date
    Aug 2004
    Often it is easier to do this type of thing in the database SQL than in PHP, using the DBMS's own date/time functions.

    If you do need/want to do it in PHP and are using a reasonably recent version of PHP, take a look at the DateTime and DateInterval classes.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center