JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

WinSCP time is an hour ahead

Fri Jul 17, 2015 3:54 pm

Suppose I create a new file at 10:15am.
If I look at the file using "ls -l" I see the time it was created is correct, 10:15am. But if I look at the same file in WinSCP it will show as 11:15am, exactly one hour ahead of actual.

If I edit the file in WinSCP and save it, let's say it's now 10:20am, WinSCP will show 11:20am as the new file date/time. But if I use "ls -l" again the actual file date/time is correct at 10:20am.

The time on the Windows system and the RPi is the same, and I'm not aware of any time adjustments in WinSCP, so I'm wondering where that extra hour is coming from when WinSCP displays the file date/time?

User avatar
DougieLawson
Posts: 39302
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 4:20 pm

Your RPi defaults to UTC but you've probably set the UTC clock off by an hour.

sudo /etc/init.d/ntp stop
sudo dpkg-reconfigure tzdata # set your local timezone that way
sudo ntpd -g -q
sudo /etc/init.d/ntp start
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 5:47 pm

But the time is correct, and all the file creation times are correct. If I use the 'date' command in a terminal it shows the correct time, the applet on the RPi taskbar shows the correct time, and if I use "ls -l" the file times in the directory are correct for when I created them.

It's only when I'm using WinSCP to connect to the RPI that ALL file times shown there are one hour ahead of the actual time as shown in a directory listing. So WinSCP seems to be adding an hour to the files timestamp when displaying it, but I can't figure out why.

I use cron to backup the RPi to a flashdrive. In cron if I'm backing up my /home/ folder then after the rsync command I add "&& touch /home/jimmy/cronRuns/backedup_home". If the command completes successfully then it will use the second command (touch) to update the file time, it's just an empty file. I can look in my cronRuns directory at each of the appropriately named files and see when each task ran, and if the file date/time wasn't updated then I know something failed because cron never executed the "touch" portion to update the files timestamp.

So I schedule a cron task for 2:00am to backup my /home/ directory. It executes on time and touches the backedup_home file to indicate the time it backed up. If I use RPi's file manager, LXterminal, or SSH in using Putty the time for backedup_home shows as 2:00am. Perfect. But if I connect to the RPi using WinSCP the files time will show as 3:00am.

I've been subtracting an hour from the time shown in WinSCP to determine when it actually ran, but I'd like to fix whatever is causing the one hour addition.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 5:54 pm

What do you mean by "looking at the file in WinSCP" or "Editing the file in WinSCP"? As far as I know WinSCP performs neither of these functions.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
DougieLawson
Posts: 39302
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 5:57 pm

What does the date command display:

My machine set to UTC has:
Fri 17 Jul 17:57:24 UTC 2015

My other machines all set to Europe/London (BST) have:
Fri 17 Jul 18:57:25 BST 2015

Yours set to Eastern should have:
Fri Jul 17 13:57:26 EDT 2015
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 6:10 pm

DougieLawson wrote:What does the date command display:

My machine set to UTC has:
Fri 17 Jul 17:57:24 UTC 2015

My other machines all set to Europe/London (BST) have:
Fri 17 Jul 18:57:25 BST 2015

Yours set to Eastern should have:
Fri Jul 17 13:57:26 EDT 2015

Code: Select all

>$ date
Fri Jul 17 14:02:11 EDT 2015
There's nothing wrong with the time on the RPi. It's WinSCP that seems to be adding an hour to the files timestamp.

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 6:19 pm

Joe Schmoe wrote:What do you mean by "looking at the file in WinSCP" or "Editing the file in WinSCP"? As far as I know WinSCP performs neither of these functions.
By "looking at the file in WinSCP" I obviously meant looking at it in a directory listing, since that's what WinSCP does. What do you think I meant that isn't a function of WinSCP? And if you right click on a file in WinSCP you can select "Edit" from the list and edit the file right there with the built-in editor. So actually WinSCP does both, that's why I like to use it. I guess I should have said "looking at a directory file list in WinSCP", but I forgot you'd be along to critique each word, I'll endeavor to be more exact with my phrasing in the future.

User avatar
DougieLawson
Posts: 39302
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 7:06 pm

Is the date and timezone set correctly on your Windows system?
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 7:48 pm

DougieLawson wrote:Is the date and timezone set correctly on your Windows system?
Yes, as I stated in my first post Windows time is correct. In fact there are 3 Windows PC's at this desk, all have the correct time, which matches my atomic clock on the wall, and logging into RPi with WinSCP from any of them does the same thing.

WinSCP always adds an hour to the files actual timestamp on disk when listing it in a WinSCP directory listing (thought I better add that last part for @Joe so he won't have to point out that WinSCP doesn't have a "listing it" function).

User avatar
jojopi
Posts: 3274
Joined: Tue Oct 11, 2011 8:38 pm

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 8:13 pm

WinSCP has several pages of documentation about various timestamp issues, although I am not sure whether any of them exactly explain the problem reported in this thread.

https://winscp.net/eng/docs/timestamp

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: WinSCP time is an hour ahead

Fri Jul 17, 2015 8:17 pm

I finally figured it out, and found the settings, it's a WinSCP thing. It adjusts the files date/time by an hour for DST since the transfer uses UTC time. Problem is it's all local and the systems clocks are already on DST, and the files timestamp is correct even after transfer, so when it lists the file and adds another hour to the files timestamp to compensate for DST it's not the correct time. I just need to adjust it to -1 hour to compensate so the files timestamp in the directory listing is the same as on the disk.

Return to “Troubleshooting”