1 2 3 4 5 6 7 | import datetime
from dateutil import tz
def encode_datetime(obj):
if isinstance(obj, datetime.datetime):
return obj.astimezone(tz.tzutc()).strftime('%Y-%m-%dT%H:%M:%SZ')
raise TypeError(repr(o) + " is not JSON serializable")
|
More like this
- isoutc template filter by japerk 3 years, 1 month ago
- JSON decode datetime by japerk 3 years, 1 month ago
- Encoding datetime for JSON consumers like YUI by acdha 2 years, 5 months ago
- timeto template filter by japerk 3 years, 1 month ago
- Another JsonResponse by kcarnold 3 years, 11 months ago
Comments