The solution for mysql query time to get the digital time: first query the digital time from the database; then use the "function timestampToTime(timestamp){...}" method in the front end to convert the timestamp into time.

Recommendation: "mysql video tutorial"
The time queried from the database is displayed as a string of numbers on the front end ?
Solution:
I encountered a problem before, and the time queried from the database was displayed as a number on the front end. The database I use is mysql. My solution is to convert it on the front end. The code is as follows:
The string of numbers queried is a timestamp. I only need to convert the timestamp into time in the frontend.
function timestampToTime(timestamp) {
var date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
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();
return Y+M+D;
}It should be noted that the timestamp queried is 10 digits or 13 digits! ! !
The above is the detailed content of What should I do if the numbers come out of mysql query time?. For more information, please follow other related articles on the PHP Chinese website!