How to Get the Current Time in Python (Summary)
In this video course, you’ve generated a datetime
object and have seen how to pick out different attributes of the object. You’ve also examined a few ways to output the datetime
object in different formats.
You’ve also acquainted yourself with Unix time and ISO timestamps and explored how you can represent your timestamp unambiguously. For this, you’ve dipped your toes into the complex world of time zones and made your datetime
object time zone aware.
To dive deeper into the datetime
module, check out Using Python datetime
to Work With Dates and Times. You can also explore the time
module with A Beginner’s Guide to the Python time
Module and Mastering Python’s Built-in time
Module.
If you’re looking to time how long things take, then check out the tutorial Python Timer Functions: Three Ways to Monitor Your Code.
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00
In this tutorial, you’ve learned how to create datetime
objects using the datetime
module’s .now()
method, as well as learned how to call specific attributes of these objects.
00:09
You’ve also learned how to use the .strftime()
method and its format codes to make timestamps more readable. You learned about what Unix time is, as well as how to work with it in Python.
00:20 If you’re interested in learning more about working with dates and times in Python, here are some additional Real Python resources that can help you learn.
00:28
The first resource, How to Get and Use the Current Time in Python, is the tutorial that this video course was based on. The second resource, Mastering Python’s Built-in time
Module, teaches you the core concepts of representing and working with dates and times in Python using Python’s built-in time
module.
00:45
Lastly, you can check out Python Timer Functions: Three Ways to Monitor Your Code if you’re interested in learning even more about how you can use the time
module in Python to monitor your code’s performance.
00:56 Thank you for taking the time to watch this course, and I really hope you enjoyed learning with me. Take care.
Become a Member to join the conversation.