我有两个日期def is_alpha(your_string):
for c in your_string:
if c not in ALPHABETS:
return False
return True
和startdate
。
如何区分两个日期以分钟为单位
currentdate
我能够减去这两个日期,但我不确定如何将输出(console.log("startdate: " + startdate + " currentdate: " + currentdate);
>> startdate: Tue Nov 10 2015 13:00:00 GMT-0800 (PST)
>> currentdate: Tue Nov 10 2015 11:55:53 GMT-0800 (PST)
console.log(startdate.getTime() - currentdate.getTime());
>> 3846736
)转换为分钟。
答案 0 :(得分:3)
转换单位:
var milliseconds = (startdate.getTime() - currentDate.getTime());
var seconds = milliseconds / 1000;
var minutes = seconds / 60;
或者,一体化:
var minutes = (startdate.getTime() - currentDate.getTime()) / 1000 / 60;
这最有可能给你一个大小数。对于四舍五入,请使用Math.floor
,Math.ceil
或Math.round
。