Skip to content

Support for 12hour Format #204

Answered by Makuna
nextecsolutions asked this question in Q&A
Discussion options

You must be logged in to vote

Checked in.

To convert a 24 hour to 12 hour with am and pm, you do this...

RtcHourAmPm hourAmPm = dt.Hour();

or

RtcHourAmPm hourAmPm = dt.HourAmPm();

then the hourAmPm object contains accessors for hour in 12 hour format and meridiem for am or pm.

Serial.print(hourAmPm.Hour());
if (hourAmPm.Meridiem() == Rtc_AM)
{
    Serial.print("am");
}
else
{
    Serial.print("pm");
}

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Makuna
Comment options

Answer selected by Makuna
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #203 on January 22, 2024 18:02.