@app.template_filter('localize_dt')
def localize_dt(dt, tzname):
 localized_dt = timezone(tzname).localize(dt)
 return localized_dt.isoformat()

@ app . template_filter ( 'localize_dt' ) def localize_dt ( dt , tzname ) : localized_dt = timezone ( tzname ) . localize ( dt ) return localized_dt . isoformat ( )
accepts a datetime object and a timezone name .