Home > Web Front-end > JS Tutorial > body text

js timestamp and ordinary time conversion method code

小云云
Release: 2018-03-07 13:26:10
Original
1767 people have browsed it

This article mainly shares with you the code of the conversion method between js timestamp and ordinary time. We will share it with you in the form of code, hoping to help you.

var timestamp1 = Date.parse(new Date());
console.log(timestamp1);  //杈撳嚭褰撳墠鏃堕棿鐨勬椂闂存埑var date = new Date(1520324618000);
console.log(date);
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? &#39;0&#39;+(date.getMonth()+1) : date.getMonth()+1) + &#39;-&#39;;
D = date.getDate() + &#39; &#39;;
h = date.getHours() + &#39;:&#39;;
m = date.getMinutes() + &#39;:&#39;;
s = date.getSeconds(); 
console.log(Y+M+D+h+m+s);
Copy after login

Related recommendations:

Detailed explanation of the conversion method between js timestamp and date format

javascript - How to convert js timestamp For time format

JS timestamp formatting function that is used the same as PHP’s date function

The above is the detailed content of js timestamp and ordinary time conversion method code. 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!