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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post

    Compare time php

    is there any standard way to compare time?

    I have a script that loads a few events, by time. If the script is kept open for a bit on a browser, the events are still loaded, but their "time" might have expired. so in order to alter these events i need to compare their times.

    ex 1:
    $event time is H:m (14:55).
    $compare=date('H:m'); (suppose now it is 15:00)

    ex 2:
    $event time is H:m (14:55).
    $compare=date('H:m'); (suppose now it is 14:30)

    How would I be able to see if $event has passed, and get the difference in the same format?
    in example 1, $event has passed.
    in example 2, there are 25 minutes still. difference is 00:25.

  • #2
    New to the CF scene
    Join Date
    Feb 2010
    Location
    Texas
    Posts
    8
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Something like this?
    PHP Code:
    $current date('H:m');
    $event_minutes        substr($event,0,2)    + (60 substr($event,3,2));
    $current_minutes    substr($current,0,2)    + (60 substr($current,3,2));

    $minutes_left max(0,$event_minutes $current_minutes);
    $time_left = ($minutes_left 60) . ':' $minutes_left 60


  •  

    Posting Permissions

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