03-12-2024 07:25 AM
Hi, I would like to convert a UTC time to a local time without the DST adjustment. Attached is an example VI that demonstrates the issue I have. When the Time Zone is set from 0-6 the local time is what I would expect. However, when the time zone is to 7 or greater there is one hour added to the local time for DST. Is there a way to make it so that there is not a DST adjustment?
Thanks in advance for your help!!
Jeff
03-12-2024 10:41 AM
Something like this may be:
I guess more elegant conversion from UTC exists, but wasn't unable to get it in LabVIEW.
03-12-2024 10:58 AM
Thanks for looking into this. Unfortunately I see the same problem with your example VI. Here's the problem:
UTC: 2024-03-09T19:00Z
TZ=+6:00
Local Time: 2024-03-10T01:00Z
TZ=+7:00
Local Time: 2024-03-10T03:00Z
You can see that when the TZ is changed to +7:00 there is a one hour DST shift. I would like the the local time to be 2024-03-10T02:00Z.
03-12-2024 11:06 AM - edited 03-12-2024 11:07 AM
Hi JHess,
@JHess wrote:
TZ=+7:00
Local Time: 2024-03-10T03:00Z
You can see that when the TZ is changed to +7:00 there is a one hour DST shift. I would like the the local time to be 2024-03-10T02:00Z.
Did DST kick in on March 10th for your local computer regional setting?
Then local time 2024-03-10T03:00 is basically the same as 2024-03-10T02:00...
One more question: why/how is 2024-03-10T03:00Z a "local time" for "TZ=+7"???
"Z" usually is (non-local) UTC time aka TZ=0!?
Or do you need 2024-03-10T02:00+07:00 instead?
Does your timestamp indicator show local or UTC time?
03-12-2024 11:34 AM
@JHess wrote:
Thanks for looking into this. Unfortunately I see the same problem with your example VI. Here's the problem:
UTC: 2024-03-09T19:00Z
TZ=+6:00
Local Time: 2024-03-10T01:00Z
TZ=+7:00
Local Time: 2024-03-10T03:00Z
You can see that when the TZ is changed to +7:00 there is a one hour DST shift. I would like the the local time to be 2024-03-10T02:00Z.
Ah, OK, got this. Then may be something like this (still not elegant):
But when we will proceed to the next Zone, its will be 03:00 again:
Is that what you're looking for?
There are also ConvertTime methods exists which intended for such conversion, but was unable to get it running because of this:
03-12-2024 12:32 PM
The LabVIEW Timing functions "Date/Time to Seconds" and "Seconds to Date/Time" say that they can convert between "local" and UTC Time, and can (separately) handle DST on (1) or off (0). I haven't played with these in years (> 10), but if they, indeed, work correctly, this seems a simple solution to this question.
Bob Schor
03-12-2024 12:48 PM
@Bob_Schor wrote:
The LabVIEW Timing functions "Date/Time to Seconds" and "Seconds to Date/Time" say that they can convert between "local" and UTC Time, and can (separately) handle DST on (1) or off (0). I haven't played with these in years (> 10), but if they, indeed, work correctly, this seems a simple solution to this question.
Bob Schor
I don't think so, Bob, because the conversion needs to be done for specific Time Stamp in specific Zone (which is differ from currently used Zone in OS). What author need is something like this, I guess:
Converting UTC to a designated time zone
DateTime timeUtc = DateTime.UtcNow;
TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone);
Console.WriteLine("The date and time are {0} {1}.",
cstTime,
cstZone.IsDaylightSavingTime(cstTime) ?
cstZone.DaylightName : cstZone.StandardName);
03-12-2024 12:56 PM
Hi Bob, I believe Andrey is right. I tried using the DST feature in the "Date/Time to Seconds" and got the same result. I also tried disabling the "Adjust for daylight saving time automatically" on my PC thinking maybe LabView uses the system clock but that didn't help either. This seems like it should be a simple thing to do but I am just stumped. I really appreciate the ideas/help from all of you.
03-12-2024 01:11 PM - edited 03-12-2024 01:12 PM
03-12-2024 02:07 PM
Hello, Gerd.
Where did you get the ISO8601 functions? I just "asked Google", and it found an "Epoch Date & Time by OpenG" offering on VIPM that I hadn't noticed (or downloaded), but the function icons look slightly different from the ones you showed.
I remember last year at NI-Connect trying to write an analysis routine for some EEG data I had recorded with Time-stamp info. I wanted to be able to look "25 seconds" after the start of recording, or (alternatively) starting at "12:14 pm". I had some "real data" I was using to test my routine, but I was "off by an hour" when I tried to make it work. Duh, I was sitting in Austin, and the data were taken on the East Coast ...
Bob Schor