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 4 years, 1 month ago
- JSON decode datetime by japerk 4 years, 1 month ago
- timeto template filter by japerk 4 years, 1 month ago
- ModelForm ExtJS JSON Encoder by tian 4 years, 4 months ago
- Django newforms ExtJS JSON Encoder by davidblewett 4 years, 11 months ago
Comments