I have a function that returns the current timestamp with date and time, but it remains static upon page load without updating (meaning: the seconds and minutes do not change in real-time).
Desired Outcome: I want the time to be continuously moving and not static.
Code
script
methods: {
currentDateTime() {
const current = new Date();
const date =
current.getFullYear() +
"-" +
(current.getMonth() + 1) +
"-" +
current.getDate();
const time =
current.getHours() +
":" +
current.getMinutes() +
":" +
current.getSeconds();
const dateTime = date + " " + time;
return dateTime;
},
}
HTML
{{ currentDateTime() }}
screenshot
https://i.sstatic.net/bc0UY.jpg
Any suggestions?