You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
607 B
19 lines
607 B
2 years ago
|
# FineUI中如何获取当前时间
|
||
|
|
||
|
## 错误写法
|
||
|
|
||
|
```
|
||
|
const date = new Date();
|
||
|
const time = date.getTime();
|
||
|
```
|
||
|
|
||
|
## 正确写法
|
||
|
|
||
|
```
|
||
|
const time = BI.getTime();
|
||
|
```
|
||
|
|
||
|
## 答案解析
|
||
|
|
||
|
首先思考一个场景: 某跨国公司系统管理员人在北京,在系统上配置数据更新时间晚上七点半。可是等到过了七点半,数据还是没有更新。这是为什么呢?原来服务器在伦敦,伦敦时间比北京时间慢7个小时,还没到更新时间呢
|
||
|
FineUI中BI.getTime方法专门这种场景做了处理,依据服务器时区进行偏移,正确的获取当前时间。
|