QTime change AM to PM and vice versa

596 Views Asked by At

I want to change the "AM" to "PM" string and vice versa in Qt.

I created a QTimeEdit in .ui and I set the displayFormat to "HH::mm a" but I always get AM even we're in afternoon now. How do I change the code to get a display either "AM" or "PM"?

I know that there's function members named amText() and pmText(), but they return a string.

2

There are 2 best solutions below

0
On

The correct format string to get AM or PM depending on the actual time is "ap". Thus, change your format string to "HH:mm ap".

0
On

you should use "h:m:s ap"