This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Time difference

Old posts that have not been replied to for several years.
Locked
G
Gorby

Time difference

Post by Gorby »

Hi,
I am trying to make a script that returns the difference between a given date and time to current date and time.
Given date and time is in this format 1991-09-26 and 23:10:10
The only thing I found that seems to do this thing is clock scan but a can't get it to work.

If you have any idea how to do this please feel free to write back.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Re: Time difference

Post by egghead »

Gorby wrote:Hi,
I am trying to make a script that returns the difference between a given date and time to current date and time.
Given date and time is in this format 1991-09-26 and 23:10:10
The only thing I found that seems to do this thing is clock scan but a can't get it to work.

If you have any idea how to do this please feel free to write back.
http://www.tcl.tk/man/tcl8.4/TclCmd/clock.htm

Code: Select all

set date 1991-09-26 
set time 23:10:10 

puts "Converting $date $time" 

set clocksecs [clock scan "$date $time"]

puts "Clock seconds: $clocksecs"

set check [clock format $clocksecs -format "%Y-%m-%d %H:%M:%S"]

puts "Back conversion: $check"
Locked