1
when_start = models.DateTimeField()
when_end = models.DateTimeField()

我怎样才能得到 和 之间的分钟when_startwhen_end

my_minutes = when_end - when_start = #number of minutes
4

2 回答 2

2

我会做

my_minutes = (when_end - when_start).total_seconds() / 60
于 2013-07-08T11:00:05.827 回答
2

当你减去时,你会得到这样的东西:

datetime.timedelta(0, 5, 41038)

要将其转换为分钟:

minutes = (when_end - when_start).total_seconds()/60
于 2013-07-08T11:04:19.600 回答