I have a chat online, I want to show the time that the user sent the message, I know I need JS for that, I've tried to do it, but it doesn't works, I call this function timeNow() everytime the user send a message, but time time that shows is the time that the user logged into the chat, I think it is not a real time hour, I was thinking, maybe I need to use Ajax or SetInterval function to do it? Can someone help me?
Date.prototype.timeNow = function () {
return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes();
}