dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Difference in hours (PHP)

  1. #1
    Join Date
    Feb 2012
    Posts
    4

    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,
    "comfirmed".
    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
    Posts
    484
    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()

    http://php.net/manual/en/function.mktime.php

    look at the user posts that should put you on the right path

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,633
    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.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

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



Recent Articles