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 3 years, 1 month ago
  2. timeto template filter by japerk 3 years, 1 month ago
  3. UTC-based astimezone filter by miracle2k 6 months, 3 weeks ago
  4. JSON decode datetime by japerk 3 years, 1 month ago
  5. Template range filter by zalun 3 years, 2 months ago

Comments

(Forgotten your password?)