Another way is to use calendar.timegm
:
future = datetime.datetime.utcnow() + datetime.timedelta(minutes=5)
return calendar.timegm(future.timetuple())
It’s also more portable than %s
flag to strftime
(which doesn’t work on Windows).
More Related Contents:
- Converting unix timestamp string to readable date
- Convert python datetime to epoch with strftime
- How to parse dates with -0400 timezone string in Python?
- Creating a range of dates in Python
- How do I calculate the date six months from the current date using the datetime Python module?
- Convert pandas timezone-aware DateTimeIndex to naive timestamp, but in certain timezone
- How to compare two dates?
- Plotting dates on the x-axis with Python’s matplotlib
- datetime dtypes in pandas read_csv
- Generate a random date between two other dates
- How do I get the UTC time of “midnight” for a given timezone?
- pandas dataframe groupby datetime month
- How to convert columns into one datetime column in pandas?
- ISO time (ISO 8601) in Python
- pandas out of bounds nanosecond timestamp after offset rollforward plus adding a month offset
- pytz localize vs datetime replace
- Find the end of the month of a Pandas DataFrame Series
- Create a day-of-week column in a Pandas dataframe using Python
- Generate a list of datetimes between an interval
- How to get current time in python and break up into year, month, day, hour, minute?
- NameError: name ‘datetime’ is not defined
- Specifying date format when converting with pandas.to_datetime
- How to monkeypatch python’s datetime.datetime.now with py.test?
- How to get the seconds since epoch from the time + date output of gmtime()?
- Datetime conversion – How to extract the inferred format?
- Parsing a date that can be in several formats in python
- Convert a column of timestamps into periods in pandas
- Python: Adding hours to pandas timestamp
- how to specify the datetime format in read_csv
- Python generating a list of dates between two dates