我正在建立一个网站,我想比较日期,但是当我这样做时,它会给我一个额外的0:00:00
,我不希望这是我的代码:
% if (datetime.datetime.strptime(row['due_date'], "%Y-%m-%d") - cur_date).days <= 0:
<kbd style="background-color: #a52c2c;">{{datetime.datetime.strptime(row['due_date'], "%Y-%m-%d").date() - cur_date.date()}}</kbd>
% elif (datetime.datetime.strptime(row['due_date'], "%Y-%m-%d") - cur_date).days <= 2:
<kbd style="background-color: #cc781e;">{{datetime.datetime.strptime(row['due_date'], "%Y-%m-%d").date() - cur_date.date()}}</kbd>
% else:
<kbd>{{datetime.datetime.strptime(row['due_date'], "%Y-%m-%d").date() - cur_date.date()}}</kbd>
% end
我知道它很乱,但是它可以正常工作,并且返回以下内容:3 days, 0:00:00
,但我不希望有多余的分钟等等。我知道这可能已经被问到了,但我什么都没看到
答案 0 :(得分:2)
这是一个比较日期的好例子。
class Child_category extends model {
public function Category(){
return $this->belongsTo(Category::class);
}
}
答案 1 :(得分:0)
from datetime import date
CurrentDay = date.today().day
print(CurrentDay)
CurrentDay 就是您想要的。它只是打印日期。