// 日期格式化返回 2019-04-01 export function getGangDate(dates) { if (dates) { const dateNew = new Date(dates) const y = dateNew.getFullYear() const m = dateNew.getMonth() + 1 const d = dateNew.getDate() return y + ‘-‘ + (m < 10 ? ‘0‘ + m : m) + ‘-‘ + (d < 10 ? ‘0‘ + d : d) } } // 日期格式化返回 2019-04-01 12:11:23 export function getGangDateMiao(dates) { if (dates) { const dateNew = new Date(dates) const y = dateNew.getFullYear() const m = dateNew.getMonth() + 1 const d = dateNew.getDate() const h = dateNew.getHours() const f = dateNew.getMinutes() const mm = dateNew.getSeconds() return y + ‘-‘ + (m < 10 ? ‘0‘ + m : m) + ‘-‘ + (d < 10 ? ‘0‘ + d : d) + ‘ ‘ + (h < 10 ? ‘0‘ + h : h) + ‘:‘ + (f < 10 ? ‘0‘ + f : f) + ‘:‘ + (mm < 10 ? ‘0‘ + mm : mm) } } // 日期格式化返回2019年04月01日 export function getWenDate(dates) { const dateNew = new Date(dates) const y = dateNew.getFullYear() const m = dateNew.getMonth() + 1 const d = dateNew.getDate() return y + ‘年‘ + (m < 10 ? ‘0‘ + m : m) + ‘月‘ + (d < 10 ? ‘0‘ + d : d) + ‘日‘ }
原文地址:https://www.cnblogs.com/lst619247/p/10668927.html
时间: 2024-10-10 21:06:47