LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format Date/Time to String -3 Hours offset to Windows System time

Hi !
 
When I use the Format Date/Time String VI, the time has an timeoffset of -3 hours to the Windows System time (OS: Windows XP). I use LabView 8.0.
Please advice me what I am doing wrong.
 
THANKS
 
Markus
0 Kudos
Message 1 of 12
(3,822 Views)
Did you wire a True constant to the UTC input? This would convert the local time to a universal time, explaining the difference:

UTC format specifies if the output string is in Universal Time or in the configured time zone for the computer. If TRUE, date/time string is in Universal Time. The default is FALSE.


Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 2 of 12
(3,792 Views)
Did you wire a True constant to the UTC input? This would convert the local time to a universal time, explaining the difference:

UTC format specifies if the output string is in Universal Time or in the configured time zone for the computer. If TRUE, date/time string is in Universal Time. The default is FALSE.


Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 3 of 12
(3,794 Views)

Unfortunately  I haven´t connect any constant to the VI (I use the default values). I have only connect the String terminal. When I debug the program and watch the String output I get the string "03.07.2006 11:48:55" but the Windows System time is 14:48. System time setting is GMT + 1hour (Amsterdam, Berlin,....).

What else could be the reason for this time offset.

Thank you in advance.

 

 

0 Kudos
Message 4 of 12
(3,784 Views)
That is sounding a bit strange. I guess that the timestamp prior to the format vi is showing the correct time? Did you connect an indicator here to compare?
I am using the same timezone as you - so this should not be the reason. What kind of format sting did you try with? Can you attatch a small vi showing the problem - just to make sure I am testing in the same environment?


Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 5 of 12
(3,775 Views)

first of all thank you for your help. I have attached a Vi called FormatTime.vi and a screenshot (formattime.pdf) with a probe window. Please have a look on the time displayed in the window and the system time in the status line of Windows XP in the right corner. here you can see the time offset.

BR Markus

 

Download All
0 Kudos
Message 6 of 12
(3,759 Views)


@MarkusWo wrote:

first of all thank you for your help. I have attached a Vi called FormatTime.vi and a screenshot (formattime.pdf) with a probe window. Please have a look on the time displayed in the window and the system time in the status line of Windows XP in the right corner. here you can see the time offset.

BR Markus


I can confirm that this VI works fine on my system: Windows XP SP2, latest patchs applied, with Amsterdam time zone (GMT +1 hour).

It seems that your Windows system is somewhat messed up. LabVIEW positively makes use of WinAPI functions to access the system time but I'm not exactly sure which function it uses to account for the timezone offset. Apparantly there is a mismatch in your configuration somewhere that causes this function to return inconsistent infromation to LabVIEW.

Have you tried to use the Get Date/Time in Seconds function and see what the timestamp control displays. There is a change that the conversion is not done through exactly the same code path and that you see a difference here, which might help NI to find the problem better.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 12
(3,738 Views)
I agree, the vi is working properly on my computer as well.
Actually I dont have a clue if there is an additional Windows setting that could be reason to the time shift but I am curious if a VBS would read another time as LabVIEW.
Please create a new textfile file on your desktop, enter the line msgbox now and save the file as time.vbs. You can start it with a double click - if the scripting host is installed and execution of vbs is not rejected by user privileges.

Does it show the correct time?
Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 8 of 12
(3,724 Views)
Hello !
 
first I tried the Get Date/Time in seconds VI. The result is the same as with the date/time to string command (-3 hours offset).
Furthermore I used the VBS function msgbox now. Here I got the the same time as the windows system time.
Have a look on the screenshot attached.
Note: A change of the windows timezone have no effect on the LV result.
I read that there are two different WinAPI time functions, one is called getsystemtime and getlocaltime.Maybe LV use the other than VBS. I can´t tested this functions since I am not familiar with API calls in LV.
 
Markus Woehrle
0 Kudos
Message 9 of 12
(3,717 Views)

Hi Markus,

      It's concievable you may find this VI useful.  It decomposes LabVIEW time (seconds since 1/1/1904) Year, Month, Day, etc.  It's useful for building timestamps that are independent of LabVIEW's timestamp functions.  Note, however, no attempt is made to accommodate DST shifts!

 

Message Edited by tbd on 07-07-2006 02:17 AM

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 10 of 12
(3,684 Views)