【发布时间】:2015-03-17 21:36:25
【问题描述】:
这是我的第一篇 Stackoverflow 帖子,请原谅我的语法。
我正在尝试在 SQLAlchemy 数据库中使用没有时区的日期时间戳中的时间戳来显示用户浏览器中的时间以及他们的时区中的时间,而不是 UTC。
这是我的 python/Flask 代码(我是初学者):
首先我查询数据库
timeclockinfo = TimeClock.query.filter_by(parent_id=current_user.parent_id, user_id=current_user.user_id, closed=1).all()
#Then I tuple the data
child_patient = zip(timeclockinfo, user_names, visit_dates )
#I render the data with Flask
return render_template('locationcheckinrpt.html', form=form, child_patient=child_patient, timeclockinfo=timeclockinfo, searchForm=searchForm)
.
.
.
#In the template I have a date time field for the records rendered
{% for times in child_time %}
{{ times[0].checkintime.strftime('%Y/%m/%d @ %I:%M %p') }}
{% endfor %}
谁能告诉我如何在浏览器用户时区而不是 UTC 中显示 UTC times[0].checkintime。
我确实让用户输入了他们的时区,所以我减去了适当的小时数。
但是,我无法将其显示出来。
【问题讨论】: