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
    New Coder
    Join Date
    Apr 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Comparing timestamps - Finding the oldest

    If I had 10 variables that were holding 10 different timestamps, and I wanted to compare them so I could find out which variable was holding the oldest timestamp, how would I go about doing that?

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    easiest way is to put thme in an array the simply sort the array
    Code:
    $time_ts[] = first timestamp;
    $time_ts[] = 2nd timestamp;
    etc
    
    then 
    
    sort($time_ts);
    
    and presuming you have 10 items
    
    $i= 0;
    for ($i = 0; $i < 10; $i ++) {
      echo $time_ts[$i];
    }

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,058
    Thanks
    10
    Thanked 96 Times in 94 Posts
    you can also use min() to find the lowest value

    PHP Code:
    <?
    echo min$time_ts ) ;
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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