The JS timestamp is 13 BITs, which contains 3 bits in milliseconds, while PHP only has 10 bits out of milliseconds, which is why it is not correct, the processing method is as follows: the timestamp imported by PHP for JS processing. Why can't I always get the correct number? The original JS timestamp is 13 BITs, which contains 3 bits in milliseconds, PHP only contains 10 characters, excluding milliseconds.
Var nowtime = (new Date ). getTime ();/* Current timestamp * // * conversion time, calculation difference */function comptime (beginTime, endTime) {var secondNum = parseInt (endTime-beginTime * 1000) /1000); // calculate the timestamp difference if (secondNum> = 0 & secondNum <60) {return secondNum + 'Seconds before ';} else if (secondNum >=60 & secondNum <3600) {var nTime = parseInt (secondNum/60); return nTime + 'minutes ago ';} else if (secondNum> = 3600 & secondNum <3600*24) {var nTime = parseInt (secondNum/3600); return nTime + 'hour before ';} else {var nTime = parseInt (secondNum/86400); return nTime + 'day before ';} t = comptime (timestamp, nowtime ); // timestamp is the timestamp returned by PHP via ajax