EldoS | Feel safer!

Software components for data protection, secure storage and transfer

UTC Time and SFTP

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#10204
Posted: 05/28/2009 09:08:16
by Glenn Deneweth (Standard support level)
Joined: 05/28/2009
Posts: 9

Since my company has many servers, I am not sure which time zone each server is in. When I list file details using sftp, I understand that the time is in UTC format, does SFTP allow me to determine what time zone the server is in? I don't want to calculate to the PCs time zone.

Thanks,

Glenn
#10207
Posted: 05/28/2009 13:43:44
by Eugene Mayevski (EldoS Corp.)

Unfortunately there's no way to determine local time zone using SFTP. But if you tell me the reason you are asking, maybe we will be able to find some workaround or solution.


Sincerely yours
Eugene Mayevski
#10285
Posted: 06/04/2009 09:30:58
by Glenn Deneweth (Standard support level)
Joined: 05/28/2009
Posts: 9

How do I go about converting UTC to GMT? I need to display the file time correctly. Some code I found doesn't take Daylight savings time into account. I'm coding this in VB unfortunately.
#10287
Posted: 06/04/2009 09:35:53
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

According to SFTP specification, all times, returned by server, are represented in UTC. So you should convert them to your local time zone, I guess.
#10288
Posted: 06/04/2009 09:36:12
by Eugene Mayevski (EldoS Corp.)

UTC doesn't have daylight time while GMT is a time zone with it's rules for daylight time transition. In Windows you can call Windows API function named SystemTimeToTzSpecificLocalTime to convert UTC to local times including GMT.


Sincerely yours
Eugene Mayevski
#10294
Posted: 06/04/2009 10:20:57
by Glenn Deneweth (Standard support level)
Joined: 05/28/2009
Posts: 9

Quote
Eugene Mayevski wrote:
UTC doesn't have daylight time while GMT is a time zone with it's rules for daylight time transition. In Windows you can call Windows API function named SystemTimeToTzSpecificLocalTime to convert UTC to local times including GMT.
Quote
Eugene Mayevski wrote:
UTC doesn't have daylight time while GMT is a time zone with it's rules for daylight time transition. In Windows you can call Windows API function named SystemTimeToTzSpecificLocalTime to convert UTC to local times including GMT.


Tried that and it was off by an hour (I assume it's daylight savings time) I changed the code to reflect this... Does this seem correct? I get the right time now. Added (tzi.DaylightBias / 60) to the DateSerial Function

' Convert UTC time to local time for current time zone
Public Function UTCtoLocal(ByVal tDate As Date) As Date
Dim tzi As TIME_ZONE_INFORMATION
Dim stUTC As SYSTEMTIME
Dim stLocal As SYSTEMTIME
Dim lRes As Long

lRes = GetTimeZoneInformation(tzi)
stUTC.wYear = Year(tDate)
stUTC.wMonth = Month(tDate)
stUTC.wDay = Day(tDate)
stUTC.wHour = Hour(tDate)
stUTC.wMinute = Minute(tDate)
stUTC.wSecond = Second(tDate)
stUTC.wMilliseconds = 0
lRes = SystemTimeToTzSpecificLocalTime(tzi, stUTC, stLocal)
UTCtoLocal = DateSerial(stLocal.wYear, stLocal.wMonth, stLocal.wDay) + TimeSerial(stLocal.wHour - (tzi.DaylightBias / 60), stLocal.wMinute, stLocal.wSecond)
End Function
#10295
Posted: 06/04/2009 11:01:47
by Eugene Mayevski (EldoS Corp.)

YOu should check MSDN article on this, there were some comments regarding the daylight bias there. I don't remember details, as this is outside of the topic of this forum.


Sincerely yours
Eugene Mayevski
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.

Reply

Statistics

Topic viewed 2002 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!