当前位置:网站首页>【时间格式工具函数的封装】
【时间格式工具函数的封装】
2022-07-07 09:08:00 【果东布丁】
timegs.js
export default function formatMsgTime (timespan) {
var dateTime = new Date(timespan) // 将传进来的字符串或者毫秒转为标准时间
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() // 将当前编辑的时间转换为毫秒
var now = new Date() // 获取本机当前的时间
var nowNew = now.getTime() // 将本机的时间转换为毫秒
var milliseconds = 0
var timeSpanStr
milliseconds = nowNew - millisecond
if (milliseconds <= 1000 * 60 * 1) { // 小于一分钟展示为刚刚
timeSpanStr = '刚刚'
} else if (1000 * 60 * 1 < milliseconds && milliseconds <= 1000 * 60 * 60) { // 大于一分钟小于一小时展示为边栏推荐
- [untitled]
- [OneNote] can't connect to the network and can't sync the problem
- Operation method of Orange Pie orangepi 4 lts development board connecting SATA hard disk through mini PCIe
- Array object sorting
- [STM32] actual combat 3.1 - drive 42 stepper motors with STM32 and tb6600 drivers (I)
- 在线硬核工具
- Hash / (understanding, implementation and application)
- Use of dotween
- Force buckle 1002 Find common characters
- IDEA快捷键大全
猜你喜欢
随机推荐
Activity生命周期
Qtcreator sets multiple qmake
解决VSCode只能开两个标签页的问题
关于在云服务器上(这里用腾讯云)安装mysql8.0并使本地可以远程连接的方法
POJ1821 Fence 题解报告
V-for img SRC rendering fails
"Dream Cup" 2017 Jiangsu information and future primary school summer camp it expert PK program design questions
[untitled]
PR Lecture Notes
【C#】WinForm运行缩放(变糊)的解决方法
Using ENSP to do MPLS pseudo wire test
Deeply understand the characteristics of database transaction isolation
uniapp 在onLaunch中跳轉頁面後,點擊事件失效解决方法
[pytorch 07] hands on deep learning chapter_ Preliminaries/ndarray exercises hands-on version
uniCloud
The sixth training assignment
Wallhaven壁纸桌面版
JS implementation chain call
How to play video on unityui
After the uniapp jumps to the page in onlaunch, click the event failure solution








![[untitled]](/img/f0/a34c116a793e844da46c7cd407224b.jpg)
