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
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    263
    Thanks
    183
    Thanked 0 Times in 0 Posts

    How to get the difference between two datetime values

    I want to get the difference between two datetime values and I don't know how,I tried to do this by making this simple way:
    $difTime = $currTime - $logTime;

    but it result "0",so I hope if there is a way to do it right.

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Assuming datetime means they are formatted as `Y-m-d H:i:s`:
    PHP Code:
    $difTime strtotime$currTime ) - strtotime$logTime ); 

  • Users who have thanked kbluhm for this post:

    Mido™ (09-12-2009)

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    263
    Thanks
    183
    Thanked 0 Times in 0 Posts
    they formatted as `Y-m-d h:i:s`.
    and thanks for help.


  •  

    Posting Permissions

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