当前位置:网站首页>[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
边栏推荐
- Array object sorting
- Creative information was surveyed by 2 institutions: greatdb database has been deployed in 9 places
- 'module 'object is not callable error
- The post-90s resigned and started a business, saying they would kill cloud database
- The database synchronization tool dbsync adds support for mongodb and es
- QT document
- RationalDMIS2022阵列工件测量
- 技术分享 | 抓包分析 TCP 协议
- The fifth training assignment
- Qtcreator sets multiple qmake
猜你喜欢
Activity生命周期
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
90后,辞职创业,说要卷死云数据库
Distributed database master-slave configuration (MySQL)
关于在云服务器上(这里用腾讯云)安装mysql8.0并使本地可以远程连接的方法
Verilog design responder [with source code]
[STM32] actual combat 3.1 - drive 42 stepper motors with STM32 and tb6600 drivers (I)
Table replication in PostgreSQL
从色情直播到直播电商
通过 Play Integrity API 的 nonce 字段提高应用安全性
随机推荐
网络协议 概念
The concept, implementation and analysis of binary search tree (BST)
关于测试人生的一站式发展建议
What if copying is prohibited?
uniCloud
【pyqt】tableWidget里的cellWidget使用信号与槽机制
Seata 1.3.0 four modes to solve distributed transactions (at, TCC, Saga, XA)
常用sql语句整理:mysql
[untitled]
Avoid mutating a prop directly since the value will be overwritten whenever the parent component
博客搬家到知乎
毕业季|与青春作伴,一起向未来!
V-for img SRC rendering fails
使用引用
electron 添加 SQLite 数据库
学习笔记|数据小白使用DataEase制作数据大屏
【C#】WinForm运行缩放(变糊)的解决方法
什么是高内聚、低耦合?
Antd select selector drop-down box follows the scroll bar to scroll through the solution
基于Retrofit框架的金山API翻译功能案例