Skip to content

Instantly share code, notes, and snippets.

@prerakmody
Created July 23, 2018 10:42
Show Gist options
  • Save prerakmody/e5522a37b73bdfa48bca3170f04bb932 to your computer and use it in GitHub Desktop.
Save prerakmody/e5522a37b73bdfa48bca3170f04bb932 to your computer and use it in GitHub Desktop.
Python Datetime
import datetime
if __name__ == "__main__":
a = datetime.datetime.strptime('2011-09-26 14:14:11.124700931'[:-3], '%Y-%m-%d %H:%M:%S.%f')
b = datetime.datetime.strptime('2011-09-26 14:15:16.432700931'[:-3], '%Y-%m-%d %H:%M:%S.%f')
diff = (b-a)
print (diff.seconds, diff.microseconds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment