Skip to content

Instantly share code, notes, and snippets.

@mschulz
Created September 25, 2024 03:47
Show Gist options
  • Save mschulz/10910f4553ada9ba07b5a46642391825 to your computer and use it in GitHub Desktop.
Save mschulz/10910f4553ada9ba07b5a46642391825 to your computer and use it in GitHub Desktop.
JSON loads of date time item
import jsondatetime as json
>>> test = '{"name": "John Doe", "born": "Thu, 1 Mar 2012 10:00:49 UTC"}'
>>> json.loads(test)
{'name': 'John Doe', 'born': datetime.datetime(2012, 3, 1, 10, 0 ,49)}
@mschulz
Copy link
Author

mschulz commented Sep 25, 2024

Installation: pip install json-datetime

Strings are parsed using dateutil.parser.parse which is fairly flexible for common datetime formats

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment