Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stanislav-chlebec/efccbc5fdba71d022edb16b4589a584e to your computer and use it in GitHub Desktop.
Save stanislav-chlebec/efccbc5fdba71d022edb16b4589a584e to your computer and use it in GitHub Desktop.
Python - Substraction of two dates
#https://stackoverflow.com/questions/466345/converting-string-into-datetime
#https://stackoverflow.com/questions/4362491/how-do-i-check-the-difference-in-seconds-between-two-dates
LOGGER.info("ALL WORKFLOWS ARE EXECUTED from " + min_start_date + " to " + max_end_date)
from datetime import datetime
#ALL WORKFLOWS ARE EXECUTED from 2021-10-13T07:41:38.696Z to 2021-10-13T07:42:02.863Z (test_fm.py:130)
a = datetime.strptime(min_start_date, '%Y-%m-%dT%H:%M:%S.%fZ')
b = datetime.strptime(max_end_date, '%Y-%m-%dT%H:%M:%S.%fZ')
LOGGER.info("ALL WORKFLOWS ARE EXECUTED in " + str((b-a).total_seconds()) + " seconds.")
2021-10-13 02:05:12 [ INFO] ALL WORKFLOWS ARE EXECUTED from 2021-10-13T08:04:46.627Z to 2021-10-13T08:05:10.322Z (test_fm.py:130)
2021-10-13 02:05:12 [ INFO] ALL WORKFLOWS ARE EXECUTED in 23.695 seconds. (test_fm.py:135)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment