LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Date/Time String function problem

I have spent a considerable amount of time this morning trying to get the 'Get Date/Time String' function to work correctly.  Regardless of the 'date format' and 'want seconds' settings I can only get a string of the form yyyy-MM-dd and HH:mm!

 

I have just discovered that the function is dependent on the settings within 'Regional and Language Options' within the Windows XP control panel.  (See attached screen dumps of examples).

 

It therefore appears to be a dangerous function as there is no way of knowing what the control panel settings of a particular machine will be. 

 

Why is this limitation / dependence is not documented in the help files?

0 Kudos
Message 1 of 7
(3,399 Views)

There are several functions that you can use to convert a time stamp to a string. The one you used can be thought of as specifically designed to do what you have observed. You can allow the user to select the date and time presentation without needing to query the OS settings from your application.

 

There is an additional function in the Time & Dialog palette called Format Date/Time String. This function allows you to specify the formatting parameters of the string regardless of the OS settings. I've attached an example (LV 7.0 format) ...

Message Edited by Phillip Brooks on 11-25-2008 07:02 AM
Message 2 of 7
(3,391 Views)

Many thanks for your reply Philip. 

 

I was aware of this solution, but my concern was that the behaviour of the 'get date/ time' function is not properly documented and seems to suggest that the vi can modifiy the displayed date and time format.  From my tests it clearly cannot, and relies completely on the OS settings.

 

i.e. if the OS time setting is HH:mm:ss.tt (i.e 10:20:25 AM) then the function will return '10:20:25 AM'  if the OS time setting is HH:mm (i.e 10:20) then the function will return '10:20' regardless of the 'Want Seconds' setting.

 

 Is this expected behaviour?

 

The only mention of the OS settings in the help file(s) is regarding the time zone. 

0 Kudos
Message 3 of 7
(3,359 Views)

Documented like this?

 

 

What version of LabVIEW do you have? The above information is from version 8.5 and the help for 7.1 shows the same thing.

Message Edited by Dennis Knutson on 11-25-2008 07:48 AM
0 Kudos
Message 4 of 7
(3,351 Views)

8.5.

 

 

0 Kudos
Message 5 of 7
(3,338 Views)
Unless I've misread the replies, it seems to me that your question has been answered. The function is working as expected, and as documented. As noted previously, if you want the date/time string to be of a specific format, then use the Format Date/Time String. That's what I always do.
0 Kudos
Message 6 of 7
(3,304 Views)

Thanks for pointing out the relevant help sections.

0 Kudos
Message 7 of 7
(3,274 Views)