isoutc template filter

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from django import template
from dateutil import tz
import datetime

register = template.Library()

@register.filter
def isoutc(value):
    if value and isinstance(value, datetime.datetime):
        return value.astimezone(tz.tzutc()).strftime('%Y-%m-%dT%H:%M:%SZ')
    else:
        return value

More like this

  1. JSON encode ISO UTC datetime by japerk 4 years, 2 months ago
  2. timeto template filter by japerk 4 years, 2 months ago
  3. JSON decode datetime by japerk 4 years, 2 months ago
  4. FuzzyDateTimeField by japerk 4 years, 2 months ago
  5. Natural language date/time form fields by jdriscoll 6 years ago

Comments

(Forgotten your password?)