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 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; D = date.getDate() + ' '; h = date.getHours() + ':'; m = date.getMinutes() + ':'; s = date.getSeconds(); console.log(Y+M+D+h+m+s);
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!