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:


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)


It is giving me this output:
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?


No I just need to check the format

HI @Kunal_Jain

Checkout this expression

DateTime.TryParseExact(,"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


lets assume following input

4:47 AM
5:15 PM

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