Returns the number of seconds since January 1st, 1970, Midnight, in Greenwich (GMT). Also known as "Unix time", "timestamp" or "epoch".
Example:
clock seconds
on Dec 10, 2004 11:44:22 AT, returns
1102686262
LV Is the epoch the same on all platforms and operating systems?
KBK - If it isn't, that's a bug. The epoch is 1970-01-01T00:00:00Z - that is, 00:00 UTC at the start of 1 January 1970. It was once true that MacOS9 and below used a different epoch, but that proved to be too confusing for everyone.
bll 2015-2-14 The epoch on DOS (and the FAT* filesystems) was 1980-01-01. clock seconds returns the seconds since 1970, so it has very nice cross platform compatibility. Congrats to whoever did that. Apparently Windows has an epoch starting in 1601. Wikipedia: System Time
RS: Find out what your epoch is, without timezone offset, with
clock format 0 -gmt 1
AMG: To find how many seconds are left in the current day (strictly using UTC day starts), try:
expr {86400 - [clock seconds] % 86400}
This math works despite the existence of leap seconds because Tcl days are always 86400 seconds long, yet Tcl seconds are slightly longer than true for "some minutes" following a leap second. Should a negative leap second ever occur, Tcl seconds would be slightly shorter to compensate. To date (2019), 27 positive leap seconds have occurred and 0 negative leap seconds, plus another 10 positive leap seconds between TAI (atomic time) and UTC at the start of 1972. So odds are good we'll never have a negative leap second.
See also clock scan for an alternate method that is capable of working in timezones other than UTC.