html52.com
我爱小程序-开发者交流社区

wxs的date 对象的getDate函数返回日期错误

问题模块 框架类型 问题类型 操作系统 工具版本
开发者工具 小程序 Bug Windows 1.02.1806120

在wxs中进行日期转换,出现的问题

2018-07-05T17:15:01.000Z  转换后变成 Fri Jul 06 2018 01:15:01 GMT+0800 (中国标准时间) 


07-05T17:15:01.000Z  转换后变成 Fri Jul 06 2018 01:15:01 GMT+0800 (中国标准时间) //格式化显示时间


//格式化显示时间

var formatDate = function (d) {

    console.log(d);

    var date = getDate(d);

    console.log(date);

    var year = date.getFullYear();

    var month = date.getMonth() + 1;

    var day = date.getDate();

    console.log(day);

    var hour = date.getUTCHours();

    var minute = date.getUTCMinutes();

    var second = date.getUTCSeconds();

    return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');

}

var formatNumber = function (n) {

    n = n.toString()

    return n[1] ? n : '0' + n

}



评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付