Comparing timestamps: Finding the oldest

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sniper007
Forum Newbie
Posts: 17
Joined: Tue May 11, 2004 8:43 pm

Comparing timestamps: Finding the oldest

Post by Sniper007 »

If I had 10 variables that were holding 10 different timestamps, and I wanted to compare them to find out which variable had the oldest timestamp, how would I go about that?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

max() function would be your best bet

/ edit

ahh beaten to it, kudos feyd.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

:D
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Just to be picky...but if you wanted the oldest timestamp, then that would be the one with the smallest value. So min() might be better than max ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

heh oops.. my bad. Good catch mark. :D
Sniper007
Forum Newbie
Posts: 17
Joined: Tue May 11, 2004 8:43 pm

Great! Thanks!

Post by Sniper007 »

"I love all you guys!! ...Especially you... aaaaahhh... AHAHAHAHA!"

-Tommy Boy
Post Reply