当前位置:网站首页>微信小程序 日期比较,计算天数
微信小程序 日期比较,计算天数
2022-06-10 14:12:00 【yechaoa】
checkDate: function(startTime,endTime) {
//日期格式化
var start_date = new Date(startTime.replace(/-/g, "/"));
var end_date = new Date(endTime.replace(/-/g, "/"));
//转成毫秒数,两个日期相减
var ms = end_date.getTime() - start_date.getTime();
//转换成天数
var day = parseInt(ms / (1000 * 60 * 60 * 24));
//do something
console.log("day = ", day);
},还是老一套
- 转毫秒
- 计算差值
- 转换成天数
得出差值之后,是计算天数,还是计算小时,都可以自行修改计算的公式的
边栏推荐
- 软件智能:aaas系统 度量衡及文法的形式规则
- erp odoo 权限管理5年系统设置经验小结 真经验分享
- 大厂必备的40个方法论
- 二叉树和图2
- Kotlin bubbling algorithm, Gaud map filters out the data whose distance between two points is less than 50, and does not repeat the display
- Flutter 页面跳转 传参,TabBar学习总结5
- How to build Haojing technology when the computing power network is brought into reality?
- Gorm设置外键
- [note] about the problem of insufficient compilation mapping memory in keil
- 这些难搞的内存问题你都懂了吗?
猜你喜欢

Gin blog summary 1

算力网络照进现实,浩鲸科技如何构建?

How to locate the hot problem of the game

Mutual transformation among lists, arrays and tensors

还在说大学排名是笑话?最新规定:世界top50大学可以直接落户上海!

二叉树和图1
[advanced MySQL] optimize SQL by using the execution plan explain (2)

Win10 virtual machine download and installation process

2022山东省安全员C证复训题库及在线模拟考试

C multithreading learning note 2
随机推荐
Anaconda installs opencv (CV2) and uses it in the jupyter notebook
C multithreading learning note 3
[discrete mathematics review series] III. concept and operation of sets
Operation of simulated examination platform for theoretical question bank of refrigeration and air conditioning equipment operation in 2022
QT将接收到的json数据(含中文)unicode转utf8
Flutter Icon Stack LIsttitle...学习总结3
【笔记】74HC573的一些记录
Simulated 100 questions and online simulated examination for safety production management personnel of hazardous chemical production units in 2022
[Chongqing University] information sharing of preliminary and second examinations (with postgraduate entrance examination group)
Do you understand all these difficult memory problems?
How to locate the hot problem of the game
算力网络照进现实,浩鲸科技如何构建?
2022危险化学品经营单位主要负责人考试题库及在线模拟考试
IIC总线的主要特点/通信过程/读写过程
[note] the environment for setting up get injectedthread script supplemented by shellcode in Windows Security III and its use
The interview at the big factory was held at 10:00 a.m. and came out at 10:09 a.m. the question was really too
[discrete mathematics review series] IV. figure
one
CVPR 2022 | 基于序列对比学习的长视频逐帧动作表示
[big guy show] aiops in the eyes of Borui data, choosing the right track and the right people