Course Content
Dealing with Dates and Times in Python
Dealing with Dates and Times in Python
What Time is it Now?
Let's expand the objects we will work with. In this section, we will learn how to work not only with dates but with times also. This time we will work with datetime
class of the datetime
library.
A datetime
object has 6 additional arguments compared to a date
object. These are hour
(0-24), minute
(0-60), second
(0-60), microsecond
(0-1000000), tzinfo
, and fold
(used for local times).
Task
Import datetime
class from datetime
library. Print current date and time using .now()
method of datetime
class. Please note, that .now()
returns local time and since the code is executed on a dedicated server it shows GMT.
Thanks for your feedback!
What Time is it Now?
Let's expand the objects we will work with. In this section, we will learn how to work not only with dates but with times also. This time we will work with datetime
class of the datetime
library.
A datetime
object has 6 additional arguments compared to a date
object. These are hour
(0-24), minute
(0-60), second
(0-60), microsecond
(0-1000000), tzinfo
, and fold
(used for local times).
Task
Import datetime
class from datetime
library. Print current date and time using .now()
method of datetime
class. Please note, that .now()
returns local time and since the code is executed on a dedicated server it shows GMT.
Thanks for your feedback!
What Time is it Now?
Let's expand the objects we will work with. In this section, we will learn how to work not only with dates but with times also. This time we will work with datetime
class of the datetime
library.
A datetime
object has 6 additional arguments compared to a date
object. These are hour
(0-24), minute
(0-60), second
(0-60), microsecond
(0-1000000), tzinfo
, and fold
(used for local times).
Task
Import datetime
class from datetime
library. Print current date and time using .now()
method of datetime
class. Please note, that .now()
returns local time and since the code is executed on a dedicated server it shows GMT.
Thanks for your feedback!
Let's expand the objects we will work with. In this section, we will learn how to work not only with dates but with times also. This time we will work with datetime
class of the datetime
library.
A datetime
object has 6 additional arguments compared to a date
object. These are hour
(0-24), minute
(0-60), second
(0-60), microsecond
(0-1000000), tzinfo
, and fold
(used for local times).
Task
Import datetime
class from datetime
library. Print current date and time using .now()
method of datetime
class. Please note, that .now()
returns local time and since the code is executed on a dedicated server it shows GMT.