Blame view
src/utils/datetime.js
969 Bytes
e7ab2c09a
![]() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/** * 时间日期相关操作 */ /** * 时间格式化 * 将 2018-09-23T11:54:16.000+0000 格式化成 2018/09/23 11:54:16 * @param datetime 国际化日期格式 */ export function format (datetime) { return formatWithSeperator(datetime, "/", ":"); } /** * 时间格式化 * 将 2018-09-23T11:54:16.000+0000 格式化成类似 2018/09/23 11:54:16 * 可以指定日期和时间分隔符 * @param datetime 国际化日期格式 */ export function formatWithSeperator (datetime, dateSeprator, timeSeprator) { if (datetime != null) { const dateMat = new Date(datetime); const year = dateMat.getFullYear(); const month = dateMat.getMonth() + 1; const day = dateMat.getDate(); const hh = dateMat.getHours(); const mm = dateMat.getMinutes(); const ss = dateMat.getSeconds(); const timeFormat = year + dateSeprator + month + dateSeprator + day + " " + hh + timeSeprator + mm + timeSeprator + ss; return timeFormat; } } |