Change time format to 24hrs


I am currently using this code

To get the current time, however how do i change the format to 24 hours and have a am or pm after it.

any help is appreciated

give a try on Now.ToString(“HH:mm”) but AM PM is usually use on the 12 hours format

1 Like

If you also want AM or PM afte rit, you can use Datetime.Now.ToString("hh:mm tt").

1 Like

Perfect thank you @Anthony_Humphries

Just for me to understand, so it is “HH:mm tt” gives in 24hrs format and “hh:mm tt” will give in 12hrs format?

That’s correct. HH gives the 24-hour format and hh gives the 12-hour format.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.