php 时间戳如何转js-PHP问题

资源魔 22 0

php 工夫戳转js的办法:起首关上相应的代码文件;而后经过“function to_date(phpstr) {...}”办法将php工夫戳转换为js工夫便可。

保举:《PHP视频教程》

php工夫戳转换为js工夫

  function to_date(phpstr) {
      str = parseInt(phpstr) * 1000;
      var newDate = new Date(str);
      var year = newDate.getUTCFullYear();
      var month = newDate.getUTCMonth() + 1;
      var nowday = newDate.getUTCDate();
      var hours = newDate.getHours();
      var minutes = newDate.getMinutes();
      var seconds = newDate.getSeconds();
      return year + "-" + month + "-" + nowday + " " + hours + ":" + minutes + ":" + seconds;//拼接 2017-2-21 12:23:43    }
  }

以上就是php 工夫戳若何转js的具体内容,更多请存眷资源魔其它相干文章!

标签: php php教程 时间戳 php故障解决 php使用问题

抱歉,评论功能暂时关闭!