Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time comparison

Status
Not open for further replies.

bebig

Technical User
Oct 21, 2004
111
US
I want to compare time.

for example,

A--> 02:35
B--> 02:45

if {A<B} {
puts "correct"
}

can it be possible to compare "Time"?

otherwise, I think..I need to compare seperately, hour & minute.

Would you please give me any comment?
 
First create a full date adding today's date...
% set Date1 "[clock format [clock seconds] -format %m/%d/%Y] 02:35:00"
01/21/2005 02:35:00
% set Date2 "[clock format [clock seconds] -format %m/%d/%Y] 02:45:00"
01/21/2005 02:45:00
Then get the seconds values out of those dates
% set numDate1 [clock scan $Date1]
1106296500
% set numDate2 [clock scan $Date2]
1106297100
Then you can compare...
% if {$numDate2 > $numDate1} {puts yes}
yes
% if {$numDate1 > $numDate2} {puts yes}
%
jicote
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top