date.toLocaleDateString is not a function
Date.parse
returns a number. You are looking for new Date
. Or, if time
already is a Date instance, just use time.toLocaleDateString()
(and make sure it really is in every call to the function)!
function formatTime(time, prefix = "") {
return typeof time == "object" ? prefix + time.toLocaleDateString() : "";
}
You can use
new Date(date).toLocaleDateString();