收藏
回答

中国标准时间转化显示错误?

time的值是中国标准化时间,但是显示到界面上NaN/NaN/NaN   NaN:NaN    

打印date显示的是【object  Object】



var timeFormat = function (time) {

var date = getDate(time);

var date_seconds = date.getTime() / 1000;

var now = getDate();

var now_seconds = now.getTime() / 1000;

var timestamp = now_seconds - date_seconds;

var timeStr = "";

if (timestamp < 60) {

timeStr = "刚刚";

} else if (timestamp >= 60 && timestamp < 60 * 60) {

var minutes = parseInt(timestamp / 60);

timeStr = minutes + "分钟前";

} else if (timestamp >= 60 * 60 && timestamp < 60 * 60 * 24) {

var hours = parseInt(timestamp / 60 / 60);

timeStr = hours + "小时前";

} else if (timestamp >= 60 * 60 * 24 && timestamp < 60 * 60 * 24 * 30) {

var days = parseInt(timestamp / 60 / 60 / 24);

timeStr = days + "天前";

} else {

var year = date.getFullYear();

var month = date.getMonth() + 1;

var day = date.getDate();

var hour = date.getHours();

var minute = date.getMinutes();

timeStr = year + "/" + month + "/" + day + " " + hour + ":" + minute;

}

return timeStr;

}


最后一次编辑于  11-25
回答关注问题邀请回答
收藏

2 个回答

  • 卢霄霄
    卢霄霄
    11-25

    getDate是啥样子的

    11-25
    赞同
    回复
  • 痛快科技
    痛快科技
    11-25

    我记得ios和android方式不同

    11-25
    赞同
    回复
问题标签