Sam*_*tar 2 javascript typescript
我有这个功能:
isAuthenticationExpired = (expirationDate: Date) => {
var now = new Date();
if (expirationDate - now > 0) {
return false;
} else {
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
这两个expirationDate和now的类型日期
打字稿给我一个错误说:
Error 3 The left-hand side of an arithmetic operation must be of type
'any', 'number' or an enum type.
Error 4 The right-hand side of an arithmetic operation must be of type
'any', 'number' or an enum type.
Run Code Online (Sandbox Code Playgroud)
我怎样才能检查日期是否已过期,因为我的方式似乎不起作用?
获取Date的日期和使用的整数值表示(自unix时期以来为ms) nowexpirationDate.valueOf()
var now = new Date().valueOf();
expirationDate = expirationDate.valueOf();
Run Code Online (Sandbox Code Playgroud)
或者,使用 Date.now()
| 归档时间: |
|
| 查看次数: |
1244 次 |
| 最近记录: |