| | |
| | | const formatTime = date => { |
| | | 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() |
| | | const moment = require('./moment.min') |
| | | |
| | | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') |
| | | |
| | | |
| | | const formatTime = date => { |
| | | const time = moment(date) |
| | | const now = moment() |
| | | |
| | | const timeYear = time.year() |
| | | const timeMonth = time.month() + 1 |
| | | const timeDay = time.date() |
| | | |
| | | const thisYear = now.year() |
| | | const thisMonth = now.month() + 1 |
| | | const thisDay = now.date() |
| | | |
| | | if (timeYear < thisYear) { |
| | | return time.format('YYYY年MM月') |
| | | } else if (timeMonth < thisMonth) { |
| | | return time.format('MM月DD日') |
| | | } else if (timeDay < thisDay) { |
| | | if (timeDay + 1 == thisDay) { |
| | | return '昨天' |
| | | } else { |
| | | return time.format('MM月DD日') |
| | | } |
| | | } else { |
| | | return time.fromNow() |
| | | } |
| | | } |
| | | |
| | | const formatNumber = n => { |