[英]Conversion to local time zone yields different value in different machine
I am storing few tweets in mongodb in UTC format and converting utc time specified in tweets to local time zone in my local machine it renders correctly in local machine but not in my server. 我以UTC格式在mongodb中存储了几条推文,并将推文中指定的utc时间转换为我的本地计算机中的本地时区,它在本地计算机中正确呈现,但在我的服务器中未正确显示。
#d is the tweet
created_at = d['created_at']
dt = datetime.datetime.strptime(created_at,\
"%a %b %d %H:%M:%S +0000 %Y")
dt = dt.replace(second = 0, minute=0)
db.collection({'created_at': dt})
here = tz.tzlocal('Asia/Colombo')
utc = tz.gettz('UTC')
for index, item in enumerate(items):
ist = item['created_at'].replace(tzinfo=utc).astimezone(here)
ist_readable = ist.replace(minute =0, second = 0).ctime()
items[index]['created_at'] = ist_readable
return items
Thu Apr 19 04:00:00 2012
Thu Apr 19 03:00:00 2012
Thu Apr 19 09:00:00 2012
Thu Apr 19 08:00:00 2012
Local machine time zone is set to 'IST', server time zone is set to 'UTC'. 本地计算机时区设置为“ IST”,服务器时区设置为“ UTC”。
here = tz.gettz('Asia/Colombo')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.