废话不多说,直接上代码!!!
export default {
//时间格式返回 方法一:
//data :传过来的时间/时间戳 type:时间返回格式类型 (可自定义)
formatDate: function(date, type) {
if (date != undefined) {
//兼容ios
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) || navigator.userAgent.indexOf("Safari") > -1) {
date = String(date).replace(/\-/g, "/")
}
var time = '';
if (date.indexOf('-') != -1 || date.indexOf('/') != -1) {
time = new Date(date)
} else {
time = new Date(JSON.parse(date))
}
var year = time.getFullYear();
var month = time.getMonth() + 1;
var date = time.getDate();
var hours = time.getHours();
var minutes &