LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to unbundle p.m and a.m from Seconds To Date/Time Function

Solved!
Go to solution

hi 

i have Seconds To Date/Time Function  and i separated it to hour,min,sec by unbundle by name function as the picture. i don't know how to separate AM PM.is it possible to separate them? if not, is there any other way?

thank you

 

0 Kudos
Message 1 of 16
(3,367 Views)

On my computer, I get a 24H time for "Hour".

 

If you get the same, then you can do Quotient and Remainder with 12 as the divisor.

If quotient is 1, then it's PM, otherwise, it's AM.

The remainder is the hours in AM/PM style.

 

Example_VI.png

 

Note also that you don't have to connect the "Get Date/Time in Seconds" function if you want the time "now" - that's the default value.

You only need to wire that input for a time that is "not now", as it were...


GCentral
0 Kudos
Message 2 of 16
(3,355 Views)
Solution
Accepted by topic author ehsan75

AM-PM.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 16
(3,353 Views)

I was going to test that out, and then I saw you did something naughty...

Spoiler
See the version tag on the snippet...

As an aside, "%<%I %p>T" (that's a capital "i") will get you the 12-hour time value for hours followed by "AM" or "PM".


GCentral
0 Kudos
Message 4 of 16
(3,351 Views)
thanks
0 Kudos
Message 5 of 16
(3,342 Views)

Caveat: I don't know if/how it'll work if you have 24h setting ...

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 16
(3,340 Views)

@Yamaeda wrote:

Caveat: I don't know if/how it'll work if you have 24h setting ...

/Y


Not sure what you mean. A timestamp has no such setting (it is always simply the number of seconds since jan 1, 1904 GMT) no matter what.

 

However if you add a %H in the same timestamp format container before a %p, it is indeed ignored.

 

In addition, the %p format code does not seem to work if your system doesn't use a system time format that uses AM/PM! That's an unpleasent surprise!

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 16
(3,278 Views)

@rolfk wrote:

@Yamaeda wrote:

Caveat: I don't know if/how it'll work if you have 24h setting ...

/Y


Not sure what you mean. A timestamp has no such setting (it is always simply the number of seconds since jan 1, 1904 GMT) no matter what.

 

However if you add a %H in the same timestamp format container before a %p, it is indeed ignored.

 

In addition, the %p format code does not seem to work if your system doesn't use a system time format that uses AM/PM! That's an unpleasent surprise!


Hmm. Worked for me last night on my computer at home and today also works.

Both PCs are running Windows 10 with a 24H system clock.

 

Here's my current result with a few format specifiers. As you mentioned, the %H seems to block the %p, but I don't really know why you'd want them both (as shown in the second string here):

Example_VI.png


GCentral
0 Kudos
Message 8 of 16
(3,239 Views)

@rolfk wrote:

In addition, the %p format code does not seem to work if your system doesn't use a system time format that uses AM/PM! That's an unpleasent surprise!


That's what i meant. 🙂

So the code isn't error proof, you'd need to first do a Format into string in a AM/PM format to extract it or something ... Hmm, some quick tests exposed a bug, i'll post in the relevant forum, though can someone test if 2019 or earlier reacts to Time stamp control properties 'Custom format' and change AM/PM <-> 24h setting?

So, the safe version is probably the previously posted Date-rec and quotient calc, as that one is always 24h.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 16
(3,227 Views)

@cbutcher wrote:

Hmm. Worked for me last night on my computer at home and today also works.

Both PCs are running Windows 10 with a 24H system clock.

 

Here's my current result with a few format specifiers. As you mentioned, the %H seems to block the %p, but I don't really know why you'd want them both (as shown in the second string here):

Example_VI.png


Interesting.

I get this with 24h:

Time stamp property bug 2.png

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 16
(3,225 Views)