1

I have Date Value as below:

Date: Tue, 31 Mar 2015 05:04:47 GMT

I need to add exact '5 Minutes' to above timestamp & get below "ISO8601 Date" value:

date_time_value = "2015-03-31T05:09:47.928187755Z"

How can I get this calculation performed in python?

Unnati Shukla
  • 342
  • 3
  • 15

1 Answers1

2
  1. Parse the input time string into a datetime object using an answer from Python: parsing date with timezone from an email
  2. parsed_datetime += timedelta(minutes=5)
  3. Use datetime.isoformat() method to get the result date_time_value string (for a naive datetime object; add Z at the end yourself if you know that the input is in UTC or (better) use an answer that produces timezone-aware datetime objects).
Community
  • 1
  • 1
jfs
  • 399,953
  • 195
  • 994
  • 1,670