当前位置:网站首页>Date formatting

Date formatting

2022-07-23 17:31:00 No overtime at the front end

var startTime = datePattern(new Date(searchForm.startTime), "yyyy-MM-dd") +
          " 00:00:00";


 export function datePattern (date, fmt) {
    
  if (!date) return ''
  if (!isValidDate(date)) return ''
  var o = {
    
    'M+': date.getMonth() + 1, //  month 
    'd+': date.getDate(), //  Japan 
    'h+': date.getHours() % 12 == 0 ? 12 : date.getHours() % 12, //  Hours 
    'H+': date.getHours(), //  Hours 
    'm+': date.getMinutes(), //  branch 
    's+': date.getSeconds(), //  second 
    'q+': Math.floor((date.getMonth() + 3) / 3), //  quarter 
    'S': date.getMilliseconds() //  millisecond 
  }
  var week = {
    
    '0': '\ Japan ',
    '1': '\ One ',
    '2': '\ Two ',
    '3': '\ 3、 ... and ',
    '4': '\ Four ',
    '5': '\ 5、 ... and ',
    '6': '\ 6、 ... and '
  }
  if (/(y+)/.test(fmt)) {
    
    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  }
  if (/(E+)/.test(fmt)) {
    
    fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\ star \ period ' : '\ Zhou ') : '') + week[date.getDay() + ''])
  }
  for (var k in o) {
    
    if (new RegExp('(' + k + ')').test(fmt)) {
    
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
    }
  }
  return fmt
}

Timestamps converted to HHMMSS

export function timestampToHHMMSS (value) {
    
  var theTime = parseInt(value)//  second 
  var theTime1 = 0//  branch 
  var theTime2 = 0//  Hours 
  if (theTime > 60) {
    
    theTime1 = parseInt(theTime / 60)
    theTime = parseInt(theTime % 60)
    if (theTime1 > 60) {
    
      theTime2 = parseInt(theTime1 / 60)
      theTime1 = parseInt(theTime1 % 60)
    }
  }
原网站

版权声明
本文为[No overtime at the front end]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207231438569313.html