Get UTC timestamp in Python
Datetime module supplies classes to work with date and time. These classes provide a number of functions to deal with dates, times and time intervals. Date and datetime are an object in Python, so when you manipulate them, you are actually manipulating objects and not string or timestamps.
Note: For more information, refer to Python datetime module with examples
2020-01-26 2020-02-04 1999-12-12 12:12:12.342380 2020-02-04 07:46:29.315237
Getting the UTC timestamp
datetime.datetime.now() to get the current date and time. Then use
tzinfo class to convert our datetime to UTC. Lastly, use the
timestamp() to convert the datetime object, in UTC, to get the UTC timestamp.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course