How to convert php timestamp to js

藏色散人
Release: 2023-03-06 17:40:02
Original
1542 people have browsed it

How to convert php timestamp to js: first open the corresponding code file; then use the "function to_date(phpstr) {...}" method to convert the php timestamp into js time.

How to convert php timestamp to js

Recommended: "PHP Video Tutorial"

Convert php timestamp to js time

  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    }
  }
Copy after login

The above is the detailed content of How to convert php timestamp to js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!