- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想获得格林威治标准时间的当前时间,比如 2015-08-21 05:13:13+00:00
在这里你可以看到 GMT 的修正是 00:00,在django 他们使用 from django.utils import timezone
和 date_to = timezone.now()
来计算当前时间。我将如何在 flask 中获得相同的功能,时间格式应该像 2015-08-21 05:13:13+00:00
而不是 2015-03-30 07:19 :06.746037+02
。我得到这个link但他们使用的是 2015-03-30 07:19:06+02
。我不想。只是 GTM 时间
以下代码在 Django 中,我想在 Flask 中使用相同的代码,这里他们使用 from django.utils import timezone
。在 Flask 中,它的等价物是什么,它以这种格式给出当前时间 2015-08-21 05:13:13+00:00
import datetime
import pytz
from django.utils import timezone
def calc_date_args(date_from, date_to, date_options):
try:
date_to = timezone.now()
print 'calc_date_args, date_to', date_to #calc_date_args, date_to 2015-08-21 05:13:13.615541+00:00
date_from = date_to - datetime.timedelta(days=float(date_options))
except Exception:
raise ValueError(_("The time delta must be a number representing "
"the time span in days"))
return date_from, date_to
最佳答案
不确定您指的是 UTC 时间还是 GMT,因为大多数机器使用 UTC 并且大多数时间戳都是 UTC。
在 Python 3 中获取 UTC 时区感知时间戳:
import datetime
def now():
"""Get timezone-aware UTC timestamp."""
return datetime.datetime.now(datetime.timezone.utc)
关于python - 在 flask 中如何获得格林威治标准时间的当前时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32136180/
根据 Android docs ,activity生命周期如下: onCreate() onStart() onResume() onPause() onStop() onDestroy() 问题是,
我有一门类(class)有很多专栏,但这个问题只需要其中三个: ---------------------------------------- | start_date | start_time
给定在同一个 Tomcat 6 上运行的两个 Web 应用程序。如果您从一个应用程序到另一个应用程序进行 http 调用,Tomcat 是否会“短路”此调用,或者它会在调用之前一直在 interweb
我是一名优秀的程序员,十分优秀!