Home > Article > Backend Development > How to convert php timestamp to js
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.
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 } }
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!