当前位置:网站首页>[encapsulation of time format tool functions]
[encapsulation of time format tool functions]
2022-07-07 11:19:00 【Guodong pudding】
timegs.js
export default function formatMsgTime (timespan) {
var dateTime = new Date(timespan) // Convert the incoming string or MS to standard time
var year = dateTime.getFullYear()
var month = dateTime.getMonth() + 1
var day = dateTime.getDate()
var hour = dateTime.getHours()
var minute = dateTime.getMinutes()
// var second = dateTime.getSeconds()
var millisecond = dateTime.getTime() // Converts the time of the current edit to milliseconds
var now = new Date() // Get the current time of the machine
var nowNew = now.getTime() // Convert local time to milliseconds
var milliseconds = 0
var timeSpanStr
milliseconds = nowNew - millisecond
if (milliseconds <= 1000 * 60 * 1) { // Less than a minute for just
timeSpanStr = ' just '
} else if (1000 * 60 * 1 < milliseconds && milliseconds <= 1000 * 60 * 60) { // More than one minute and less than one hour are displayed as
边栏推荐
猜你喜欢
随机推荐
Static semantic check of clang tidy in cicd
verilog设计抢答器【附源码】
Web端自动化测试失败的原因
Bookmarking - common website navigation for programmers
网络协议 概念
基于华为云IOT设计智能称重系统(STM32)
面试被问到了解哪些开发模型?看这一篇就够了
The concept, implementation and analysis of binary search tree (BST)
uniCloud
测试优惠券要怎么写测试用例?
Drive HC based on de2115 development board_ SR04 ultrasonic ranging module [source code attached]
LeetCode - 面试题17.24 最大子矩阵
创意信息获2家机构调研:GreatDB 数据库已在9地部署
分布式数据库主从配置(MySQL)
Project ERROR: Unknown module(s) in QT: core gui
2021-04-08
Socket socket programming
The seventh training assignment
Go redis Middleware
How to remove addition and subtraction from inputnumber input box