Python datetime different from iPhone date
在Google App Engine中,我有一个带有
编辑:显然,Python日期是UTC格式。但是我的iPhone日期是哪种格式?我以为
编辑2:知道了。需要在Objective-C
中执行此操作
1 2 | NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; [formatter setTimeZone:timeZone]; |
这是因为应用引擎始终在UTC时间运行,因此您的手机可能处于不同的时区。
The runtime's TZ environment variable is set to UTC, and can't be changed. Timestamps returned by e.g. time.time() and datetime.datetime.now() will always be in UTC. Similarly, datetime properties in the datastore will always be stored and returned as UTC.
You can change the time zone of a datetime in memory with the astimezone() method.
来源