当前位置:网站首页>[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 
原网站

版权声明
本文为[Guodong pudding]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070907461451.html