Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get file modified date as GMT time

27 views
Skip to first unread message

Alexandru

unread,
Jun 22, 2018, 10:57:14 AM6/22/18
to
Hi,

What is the best way get the modified date of a file as GMT time?

Currently using:

clock scan [clock format [file mtime $path]] -gmt 1

Is there a shorter way?

Regards
Alexandru

Brad Lanam

unread,
Jun 22, 2018, 12:06:28 PM6/22/18
to
A timestamp has no time zone applied.
The time zone is used for display purposes only (clock format).

% file mtime ballroomdj.tcl
1529040755
% set path ballroomdj.tcl
ballroomdj.tcl
% clock scan [clock format [file mtime $path]] -gmt 1
1529040755
%

Alexandru

unread,
Jun 22, 2018, 12:13:45 PM6/22/18
to
Perhaps I it's unclear what I mean.
Let's immagine that two persons change the same file at the exact same moment on their computers. If first person lives in New York and the second person in Berlin, the two file will have different dates, although they were changed at the same time. If I want to compare the files and see which file is older, the I need a common time measure. That would be the GMT.

Brad Lanam

unread,
Jun 22, 2018, 12:20:33 PM6/22/18
to
https://en.wikipedia.org/wiki/Unix_time

https://superuser.com/questions/405298/file-dates-are-same-in-different-timezones-in-windows

Time zones are only used in the display of time.
The unix/windows time is already GMT.

Brad Lanam

unread,
Jun 22, 2018, 12:22:24 PM6/22/18
to
On Friday, June 22, 2018 at 9:20:33 AM UTC-7, Brad Lanam wrote:
> https://superuser.com/questions/405298/file-dates-are-same-in-different-timezones-in-windows


Whoops, that superuser link is no good.
I only glanced at the content and did not read it.

Alexandru

unread,
Jun 22, 2018, 6:40:49 PM6/22/18
to
So "[file mtime $path" already givess me the time in GMT? That's cool. So I can always compare the dates of files, no mather what time region?

Brad Lanam

unread,
Jun 22, 2018, 6:56:00 PM6/22/18
to
On Friday, June 22, 2018 at 3:40:49 PM UTC-7, Alexandru wrote:
> Am Freitag, 22. Juni 2018 18:20:33 UTC+2 schrieb Brad Lanam:
> > On Friday, June 22, 2018 at 9:13:45 AM UTC-7, Alexandru wrote:
> > > Am Freitag, 22. Juni 2018 18:06:28 UTC+2 schrieb Brad Lanam:
> > > > On Friday, June 22, 2018 at 7:57:14 AM UTC-7, Alexandru wrote:
> > > > > Hi,
> > > > >
> > > > > What is the best way get the modified date of a file as GMT time?
> > > > >
> > > > > Currently using:
> > > > >
> > > > > clock scan [clock format [file mtime $path]] -gmt 1
> > > > >
> > > > > Is there a shorter way?
> > > > >
> > > > > Regards
> > > > > Alexandru
> > > >
> > > > A timestamp has no time zone applied.
> > > > The time zone is used for display purposes only (clock format).
> > > >
> > > > % file mtime ballroomdj.tcl
> > > > 1529040755
> > > > % set path ballroomdj.tcl
> > > > ballroomdj.tcl
> > > > % clock scan [clock format [file mtime $path]] -gmt 1
> > > > 1529040755
> > > > %
> > >
> > > Perhaps I it's unclear what I mean.
> > > Let's immagine that two persons change the same file at the exact same moment on their computers. If first person lives in New York and the second person in Berlin, the two file will have different dates, although they were changed at the same time. If I want to compare the files and see which file is older, the I need a common time measure. That would be the GMT.
> >
> > https://en.wikipedia.org/wiki/Unix_time
> >
> > Time zones are only used in the display of time.
> > The unix/windows time is already GMT.
>
> So "[file mtime $path" already givess me the time in GMT? That's cool. So I can always compare the dates of files, no mather what time region?

Correct.

Files that get transferred across computers may not have their modification time
preserved unless the transfer process explicitly preserves it.

But comparing two files on different computers and transferring the modification
time will work fine, or comparing the modification time via a networked file system is fine.

Gerhard Reithofer

unread,
Jun 24, 2018, 4:29:44 AM6/24/18
to
Hi,

On Fri, 22 Jun 2018, Brad Lanam wrote:
> On Friday, June 22, 2018 at 3:40:49 PM UTC-7, Alexandru wrote:

...

> > > > > > What is the best way get the modified date of a file as GMT time?
...

> Correct.
>
> Files that get transferred across computers may not have their modification time
> preserved unless the transfer process explicitly preserves it.
>
> But comparing two files on different computers and transferring the modification
> time will work fine, or comparing the modification time via a networked file system is fine.

I had a problem ca. 10 years ago, but I think it's still an issue on
CIFS/SMB that the DST is handled by the server and therefore the file
time may change!

Even inside of Windows the time was interpreted differently by the
applications like Cmd, Powershell, self compiled Posix C program and
also Wish/Tclsh of course. Therefore also the unix view on the same
file compared to the Windows view was not predictable in my environment.

What extenuated the problem was that the diferrence was exactly 3600
seconds was a good approach to analyze the situation.

It was communicated by MS professionals as known problem and solving it
would break mass of applications.

A few links - google will bring more:
https://superuser.com/questions/405298/file-dates-are-same-in-different-timezones-in-windows
http://www-01.ibm.com/support/docview.wss?uid=isg3T1026850
http://samba.2283325.n4.nabble.com/Wintertime-summertime-difference-Samba-servers-show-wrong-time-td2412989.html

Bye,
Gehard

--
Gerhard Reithofer - Techn. EDV Reithofer - http://www.tech-edv.co.at
0 new messages