当前位置:网站首页>[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
边栏推荐
猜你喜欢
随机推荐
Rolling puddle Uni_ App (VIII)
90后,辞职创业,说要卷死云数据库
测试优惠券要怎么写测试用例?
Array object sorting
IDEA快捷键大全
Audit migration
After the uniapp jumps to the page in onlaunch, click the event failure solution
Learning notes | data Xiaobai uses dataease to make a large data screen
JS array delete the specified element
From pornographic live broadcast to live broadcast E-commerce
变量的解构赋值
從色情直播到直播電商
對比學習之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
面试被问到了解哪些开发模型?看这一篇就够了
[pyqt] the cellwidget in tablewidget uses signal and slot mechanism
Web端自动化测试失败的原因
The post-90s resigned and started a business, saying they would kill cloud database
Vuthink正确安装过程
高考作文,高频提及科技那些事儿……
Drive HC based on de2115 development board_ SR04 ultrasonic ranging module [source code attached]