System Time format check

I need to check the system time format whether it is in 12 hours or 24 hours using UiPath code.
How to do it, Can anyone suugest?

Check this expression:

Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern

If it contains “tt” then you have format with 12 hours

we would recommend to illustrate your case more in detail along with some samples of the input. The request leads to some doubts: what for base is to check: string? How about the formats 12 PM or only 12 (then it has the risk to be ambiguous)

Thanks

It is giving me this output:
HH:mm
What does this means??

Well I just need the code to check whether the system’s time is in the 24 hours format or 12 hours format
Currently it shows 4:47 AM
so I just need the format of the time to check it for several machines.

Hello @Kunal_Jain

If the format is different do you need to change it to any particular standard format?

Thanks

No I just need to check the format

HI @Kunal_Jain

Checkout this expression

DateTime.TryParseExact(System.DateTime.now.ToString,"MM/dd/yyyy hh:mm:ss",system.Globalization.CultureInfo.InvariantCulture,system.Globalization.DateTimeStyles.None,nothing)

If this return true it is 12 hours if not it is 24 hours

Regards
Sudharsan

lets assume following input

4:47 AM
5:15 PM
2:45
14:57

then we could use TryParseExact and decide depending on the AM / PM addition