Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: time difference

  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Arrow time difference

    how calculate two indian time difference in php...

    And sum of two or more times...

  • #2
    New Coder
    Join Date
    Jan 2006
    Posts
    73
    Thanks
    2
    Thanked 3 Times in 3 Posts
    PHP Code:
    function timedifference($time1$time2)
    {
        
    $time1 strtotime($firstTime);
        
    $time2 strtotime($lastTime);

        
    $timedifference $time2-$time1;

        return 
    $timedifference;

    Same time zone, correct? That should do fine. For sum just change the negative to a positive and possibly just add additional parameters.

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    $timedifference = abs($time2-$time1);

    absolute makes the difference always positive.


  •  

    Posting Permissions

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