I am making extension. I get date and time with "getDateAndTime();" function.
function getDateAndTime() {
return (date.getDate()<10? "0" : "") + date.getDate() + " " + months_tr[date.getMonth()] + " " + date.getFullYear() + " - " + (date.getHours()<10? "0" : "") + date.getHours() + "." + (date.getMinutes()<10? "0" : "") + date.getMinutes();
}
The first time the extension runs, the date and time are updated, but then when the function is called again, the data is not updated.
How can I keep the date and time up to date?
You have a date variable that declared out of the function. It's declared once so it will remain the same.
I guess you want to add:
function getDateAndTime() {
const date = new Date();
....
}
It means that the date is updated for everyone calls this function.