LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Changing hours in files (https://www.linuxquestions.org/questions/linux-newbie-8/changing-hours-in-files-4175637188/)

Entropy1024 08-26-2018 03:25 PM

Changing hours in files
 
I'm moving files from a server in NY to a PC in London. All the files are timestamped with East coast time, ie 5 hours behind UK time.
I would like to change them to UK time. Is there some way to advance the hour on each file by five hours?

Many thanks

scasey 08-26-2018 03:44 PM

Code:

man touch
'tho if you want to preserve the date and only change the time, there will be some scripting involved.

Still, touch is the starting place.

Turbocapitalist 08-26-2018 03:47 PM

From what I understand the date and time of the files is stored independently of the timezone it is displayed in. The actual time is in Epoch seconds so if your transfer method preserves the time and date, then in the new timezone the correct time will be displayed. So 12:01 Eastern will be 17:01 UTC.

If you want to see the files in a different zone, set the environment variable accordingly.

Code:

touch foo;
ls -lh foo;
TZ='Europe/Berlin' ls -lh foo;
TZ='Europe/London' ls -lh foo;

On the remote system the time zone will be different but the file the "same" age as always.

Which means are you using to transfer the files?

syg00 08-26-2018 07:55 PM

Quote:

Originally Posted by Turbocapitalist (Post 5896274)
From what I understand the date and time of the files is stored independently of the timezone it is displayed in. The actual time is in Epoch seconds ...

Interesting - I always though it was store as a UTC value, but debugfs suggests you are correct. For atime and mtime the value can be set by for example "touch", however the creation time (from touch) is always the real epoch offset of the actual creation of the file. The things you learn ...


All times are GMT -5. The time now is 04:15 PM.