How can js, delay printing the current time?

topic description

it takes a few seconds to print out the current time

related codes

/ / Please paste the code text below (do not replace the code with pictures)
have tried the following ways, but the time printed is the time when the code is running

let time = new Date();
console.log(time);
setTimeout(() => {
    let data = new Date();
    console.log(time);
}, 5000);

what result do you expect? What is the error message actually seen?

I hope to be able to print out the current time in 5 seconds

Mar.03,2022

No problem. What is printed after 5 seconds is the time set by the global variable, that is, the time before 5 seconds.


you console.log (time); that's certainly the same time


modify to:

setTimeout(() => {
 console.log(+new Date());
}, 5000);

or

setTimeout(() => {
  let time = +new Date();
  console.log(time );
}, 5000);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e530-2bc59.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e530-2bc59.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?