django获取今天的时间

from django.utils import timezone #引入timezone模块
time_now = timezone.now() #输出time_now即为当然日期和时间

#输出time_now

time_now  为 datetime.datetime(2018, 7, 16, 3, 47, 6, 44932, tzinfo=<UTC>)

可以使用strftime方法把获取的时间变为我们想要的格式

strftime( "%Y-%m-%d")

猜你喜欢

转载自blog.csdn.net/qq_37953017/article/details/81062618