guci-date
Version:
A golden bottle of sake costs ten thousand yuan, and a jade plate costs ten thousand yuan.
18 lines (17 loc) • 675 B
JavaScript
export const fromData = function (value) {
const date = new Date(value)
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
// 位数不够两位,前面加0
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
};
// 判断是手机端还是pc端
export const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);