一個事件類models.py轉換UTC時間從DateTimeField字段(models.py)本地時間
class Event(models.Model):
timestamp = models.DateTimeField()
message = models.TextField()
def __unicode__(self):
return "'%s' at %s" % (self.message, self.timestamp)
def api_detail(self):
return {
'timestamp': str(self.timestamp),
'description': self.message,
沒有保存在數據庫UTC時間。但我想在本地化時間取回它。例如,時間戳將返回:2012年2月14日,下午7點。。這次是UTC,我想把它改成當地時間。
請幫我看看這個問題:)
重複:http://stackoverflow.com/questions/1745436/how-to-manage-timezones-in-a-web-application – 2012-02-08 07:17:08