Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
12-Hour and 24-Hour Formats | Working with Times
Dealing with Dates and Times in Python
course content

Зміст курсу

Dealing with Dates and Times in Python

Dealing with Dates and Times in Python

1. Working with Dates
2. Working with Times
3. Timezones and Daylight Savings Time (DST)
4. Working with Dates and Times in pandas

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 codeMeaningExample
%HHour (24-hour clock) as a zero-padded decimal number00, 01, ..., 22, 23
%IHour (12-hour clock) as a zero-padded decimal number01, 02, ..., 11, 12
%pLocale’s equivalent of either AM or PMAM, PM

Завдання

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.

Завдання

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.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 6
toggle bottom row

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 codeMeaningExample
%HHour (24-hour clock) as a zero-padded decimal number00, 01, ..., 22, 23
%IHour (12-hour clock) as a zero-padded decimal number01, 02, ..., 11, 12
%pLocale’s equivalent of either AM or PMAM, PM

Завдання

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.

Завдання

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.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 6
toggle bottom row

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 codeMeaningExample
%HHour (24-hour clock) as a zero-padded decimal number00, 01, ..., 22, 23
%IHour (12-hour clock) as a zero-padded decimal number01, 02, ..., 11, 12
%pLocale’s equivalent of either AM or PMAM, PM

Завдання

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.

Завдання

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.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

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 codeMeaningExample
%HHour (24-hour clock) as a zero-padded decimal number00, 01, ..., 22, 23
%IHour (12-hour clock) as a zero-padded decimal number01, 02, ..., 11, 12
%pLocale’s equivalent of either AM or PMAM, PM

Завдання

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.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 6
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt