当前位置:网站首页>Wechat applet timestamp conversion time format + time subtraction
Wechat applet timestamp conversion time format + time subtraction
2022-06-11 16:33:00 【EOPG】
Wechat applet timestamp conversion time format + Time minus
One 、 The timestamp is converted to days , when , branch , second
- newly build ***util.js, Copy the following code
/** Timestamp format days **/
function computationTime (total) {
total = total / 1000;
// Calculate integer days
let day = parseInt(total / (24 * 60 * 60));
// Gets the number of seconds remaining after the number of days is calculated
let afterDay = total - day * 24 * 60 * 60;
// Calculate integer hours
let hour = parseInt(afterDay / (60 * 60));
// Gets the number of seconds remaining after the calculated hours
let afterHour = total - day * 24 * 60 * 60 - hour * 60 * 60;
// Calculate integral minutes
let min = parseInt(afterHour / 60);
// Calculate the number of seconds left after minutes
let afterMin = total - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60;
return {
day,
hour,
min,
afterMin: Math.ceil(afterMin)
};
}
module.exports = {
computationTime: computationTime
}
- In need of js Introduced inside
import {
computationTime} from "../../utils/jpxutil.js";
- Direct reference to tool functions , Enter timestamp return days , when , branch , second
let time = new Date("2022-06-10 11:40:01");
let time1 = new Date("2022-06-09 10:40:00");
let tt = time.getTime() - time1.getTime();
console.log(computationTime(tt));
Two 、 Subtracting time into days , when , branch , second
Basically consistent with the above
Code up
/** Time minus */
function timeDifference (newTime, oldTime){
let time1 = new Date(newTime);
let time2 = new Date(oldTime);
return computationTime(time1 - time2);
}
/** Timestamp format days **/
function computationTime (total) {
total = total / 1000;
// Calculate integer days
let day = parseInt(total / (24 * 60 * 60));
// Gets the number of seconds remaining after the number of days is calculated
let afterDay = total - day * 24 * 60 * 60;
// Calculate integer hours
let hour = parseInt(afterDay / (60 * 60));
// Gets the number of seconds remaining after the calculated hours
let afterHour = total - day * 24 * 60 * 60 - hour * 60 * 60;
// Calculate integral minutes
let min = parseInt(afterHour / 60);
// Calculate the number of seconds left after minutes
let afterMin = total - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60;
return {
day,
hour,
min,
afterMin: Math.ceil(afterMin)
};
}
module.exports = {
computationTime: computationTime,
timeDifference: timeDifference
}
边栏推荐
- 基于udp端口猜测的内网穿透
- 数据库备份(Mysql)
- Complete test process [Hangzhou multi tester] [Hangzhou multi tester \wang Sir]
- Laravel 2020-01-01t00:00:00.000000z date conversion
- 信息收集常用工具及命令
- A team of heavyweights came to the "digital transformation" arena of CLP Jinxin ice and snow sports
- 2022 high altitude installation, maintenance and demolition test simulation 100 questions and online simulation test
- Project workspace creation steps - Zezhong ar automated test tool
- What is RS stamp paper?
- The flat life of older farmers from Beijing to Holland
猜你喜欢

面试经典题目:怎么做的性能测试?【杭州多测师】【杭州多测师_王sir】

LeetCode——42. 接雨水(双指针)

学生网站模板棕色蛋糕甜品网站设计——棕色蛋糕甜品店(4页) 美食甜品网页制作期末大作业成品_生鲜水果网页设计期末作业

Text driven for creating and editing images (with source code)

Web page design example assignment -- Introduction to Henan cuisine (4 pages) web final assignment design web page_ Dessert and gourmet college students' web design homework finished product

20 full knowledge maps of HD data analysis have been completed. It is strongly recommended to collect them!

tornado环境搭建及基本框架搭建——熟悉的hello world

想学好ArrayList,看完这篇就够了

基于文本驱动用于创建和编辑图像(附源代码)

Toolbar details of user interface - autorunner automated test tool
随机推荐
[从零开始学习FPGA编程-17]:快速入门篇 - 操作步骤2-5- VerilogHDL硬件描述语言符号系统与程序框架(软件程序员和硬件工程师都能看懂)
Search and graph theory: Dijkstra finding the shortest path i-dijkstra (shortest path)
Laravel 8 realizes database backup through task scheduling
Leetcode 450. 删除二叉搜索树中的节点
Differences between list and set access elements
2022年安全员-B证国家题库及模拟考试
RSP:遥感预训练的实证研究
Enterprise purchase, sales and inventory management system based on SSM framework [source code + database + design]
2022年R1快開門式壓力容器操作考試題庫及模擬考試
面试高频算法题---最长回文子串
面试经典题目:怎么做的性能测试?【杭州多测师】【杭州多测师_王sir】
[learn FPGA programming from scratch -18]: quick start chapter - operation steps 2-6- VerilogHDL sequential circuit syntax analysis (taking the counter as an example)
solr(二)solr添加core以及依赖包路径
tornado环境搭建及基本框架搭建——熟悉的hello world
类的 prototype 属性和__proto__属性,类原型链有两条继承路线
How the autorunner automated test tool creates a project -alltesting | Zezhong cloud test
网络流媒体协议的联系与区别(RTP RTCP RTSP RTMP HLS)
2022 R1 quick opening pressure vessel operation test question bank and simulation test
Interview classic question: how to do the performance test? [Hangzhou multi surveyors] [Hangzhou multi surveyors \wang Sir]
Laravel 2020-01-01t00:00:00.000000z date conversion