Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2010
    Thanked 0 Times in 0 Posts

    php calculate time differance problem

    hi i have this code

    $sqlstr13="SELECT * FROM barcode WHERE Internal ='$preinternal' ";

    $result13= mysql_query($sqlstr13);
    $recordinput13= mysql_fetch_array($result13);


    $today2 = date("G:i:s");

    so now i`m subtracting


    in hear working perfectly for the time differance less than 1 minte

    but time differance above 1 min it will give zero

    plz help me to solve this problemmmmmmmm

    with the code

  • #2
    Master Coder
    Join Date
    Jun 2003
    Cottage Grove, Minnesota
    Thanked 1,096 Times in 1,087 Posts
    This line:
    $today2 = date("G:i:s");

    Should be:

    This line:

    Change to:

    time() is the UNIX timestamp right now, for your timezone.
    Remember that you're using the server timezone unless you specify it otherwise.

    The next issue will be the format of $recordinput13['timeB']
    Can you show us how one of those values are formated in the column?

    The difference between two UNIX timestamps is in seconds (that's the resolution);
    So, you might get a difference of 97. That's 97 seconds. Or a negative difference is possible.

    Last edited by mlseim; 01-18-2012 at 03:41 PM.


    Posting Permissions

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