General: add functionality to convert datetime object to timestamp
See original GitHub issueOverview
we currently can convert a string in “MM-DD-YYYY HH:MM:SS” format. Want to add functionality of taking a datetime object and converting to a timestamp
Specification
date_time = datetime.datetime.fromisoformat("2020-10-15 12:00:00")
new_date_time_obj = date_time.replace(tzinfo=timezone.utc)
return int(new_date_time_obj.timestamp())
Dependencies
None
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to Convert DateTime to UNIX Timestamp in Python
The datetime.now() function is used to obtain the current time. The mktime method is a time method that is the inverse function of...
Read more >Python Timestamp With Examples - PYnative
We can convert a datetime object into a timestamp using the timestamp() method. If the datetime object is UTC aware, then this method...
Read more >Converting datetime.date to UTC timestamp in Python
To convert datetime.datetime (not datetime.date ) object that already represents time in UTC to the corresponding POSIX timestamp (a float ).
Read more >How do I convert a datetime to a UTC timestamp in Python?
You can use the datetime module to convert a datetime to a UTC ... This function returns the time since epoch for that...
Read more >Python timestamp to datetime and vice-versa - Programiz
In this article, you will learn to convert timestamp to datetime object and datetime object to timestamp (with the help of examples).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
timedelta might also be nice to add. I had thought about correcting the time for it, but that seems like it would lead to a lot of contextual errors. I think more directly just converting timedeltas (in string or
datetime.timedelta
object formats) to their integer equivalent in seconds:I can add timedelta to TimestampConverter. I will make a new issue