LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert string to timestamp

Solved!
Go to solution

Hooovahh - in your example, it appears that it does not show the hour time offset at the end of the ISO "Z" specifier. When I run that VI, I get this:

 

2015-09-04T14:46:27.022Z

 

Shouldn't it be 2015-09-04T14:46:27.022-4:00?

0 Kudos
Message 11 of 23
(3,319 Views)

@Eric1977 wrote:

 

 

Shouldn't it be 2015-09-04T14:46:27.022-4:00?


Oh not sure, I just copied the string from the LAVA link.  The one I did apparently shows the time as UTC.

0 Kudos
Message 12 of 23
(3,318 Views)

@Eric1977 wrote:

Hooovahh - in your example, it appears that it does not show the hour time offset at the end of the ISO "Z" specifier. When I run that VI, I get this:

 

2015-09-04T14:46:27.022Z

 

Shouldn't it be 2015-09-04T14:46:27.022-4:00?


I'm not too familiar with this specific format, but I know if you make it %Z, you end up with the timezone specifier. I'm not sure how to get the offset like that.

Timestamp String (1).png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 13 of 23
(3,314 Views)

@James.M wrote:

I'm not too familiar with this specific format, but I know if you make it %Z, you end up with the timezone specifier. I'm not sure how to get the offset like that.


I never realized this but I'm guessing this was the intention.  Looks like someone needs to update their signature.

 

EDIT:  It looks like lower case z is close.

 

http://zone.ni.com/reference/en-XX/help/371361J-01/glang/codes_for_time_format_str/

0 Kudos
Message 14 of 23
(3,304 Views)

But he's in the 500 club.

 

It seems like maybe there was a syntax change at some point? Why would all the people in that thread go along with the method posted there if it didn't spit out the timezone correctly? There are snippets and everything. Did nobody test it??

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 15 of 23
(3,295 Views)

Maybe it didn't matter since it was already UTC?  So you could just add -0:00?  Easy to miss, I guess.  I didn't realize until today that is was required to be part of the ISO format for time.

0 Kudos
Message 16 of 23
(3,286 Views)

The %z seems reduntant because the "^" makes it UTC. Without that, I get "2015-09-04T08:17:16.082 -07:00:00" (with current time used), in which case the offset is nice to have.

 

Meh, I think people in that thread must not have known what they were looking at. Hopefully Eric here can make due with %z.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 17 of 23
(3,278 Views)

@James.M wrote:

 

Hopefully Eric here can make due with %z.


Yeah if not you can still do some string parsing and remove the last three characters.  I tried converting it back and it seemed to work.

0 Kudos
Message 18 of 23
(3,268 Views)
This format worked for me to get the proper time offset. I had to remove the carrot and add a percent time to the lower case Z. --> %<%Y-%m-%dT%H:%M:%S%3u%z>T I'm guessing that to get the UTC time I need to subract -4:00? I'm not up on my time formats. :-/ And to the OP, sorry for hijacking your thread. I've learned something again!
0 Kudos
Message 19 of 23
(3,260 Views)

So I pinged someone in that thread and they knew what they were doing and we didn't.

 

The "Z" at the end indicates that the time is in UTC format, and there for the timezone information isn't needed.  This is aparently correct for the ISO 8601 standard.

 

So one form that is valid is:

 

2015-09-04T11:52:51.049-04:00

 

Another is:

 

2015-09-04T15:52:51.049Z

0 Kudos
Message 20 of 23
(3,245 Views)