Add 2 hours and 1 day onto a timestamp in django
i have a model which holds data for a game, how would i add 2 hours and 1 day onto the开发者_运维问答 'starts' field?
class Game(models.Model):
starts = models.DateTimeField(auto_now_add=True)
ends = models.DateTimeField()
does anyone have a solution for this?
from datetime import timedelta
obj.starts += timedelta(days=1, hours=2)
精彩评论