12-Hour and 24-Hour Formats
Let's discuss one more moment with times - 12 and 24-hour formats. Many countries use the 24-hour format in documents, but 12-hour format in daily communication. At the same time, many countries use the 12-hour time format only. So, we need to learn how to deal with and be able to format such times.
There are several more format codes to deal with this issue.
Format code | Meaning | Example |
---|---|---|
%H | Hour (24-hour clock) as a zero-padded decimal number | 00, 01, ..., 22, 23 |
%I | Hour (12-hour clock) as a zero-padded decimal number | 01, 02, ..., 11, 12 |
%p | Locale’s equivalent of either AM or PM | AM, PM |
Swipe to start coding
Given datetime object dt
with date 28 June 2002 and time 14:58:41. Extract the time into two formats: 14:58 and 02:58 PM.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 3.23
12-Hour and 24-Hour Formats
Sveip for å vise menyen
Let's discuss one more moment with times - 12 and 24-hour formats. Many countries use the 24-hour format in documents, but 12-hour format in daily communication. At the same time, many countries use the 12-hour time format only. So, we need to learn how to deal with and be able to format such times.
There are several more format codes to deal with this issue.
Format code | Meaning | Example |
---|---|---|
%H | Hour (24-hour clock) as a zero-padded decimal number | 00, 01, ..., 22, 23 |
%I | Hour (12-hour clock) as a zero-padded decimal number | 01, 02, ..., 11, 12 |
%p | Locale’s equivalent of either AM or PM | AM, PM |
Swipe to start coding
Given datetime object dt
with date 28 June 2002 and time 14:58:41. Extract the time into two formats: 14:58 and 02:58 PM.
Løsning
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 3.23single