I am learning ASP. I know I can display current date and time using <%=now%>. But it shows static time, I want the time to be running. Also, how can I display it depending on the physical location of the person viewing the webpage. Please help.
I believe such a thing would have to be implemented client-side if you wanted it to be ticking (while staying within reason). Someone will have to correct me if theres simply a simple asp.net way to do this. As far as I know you'll want javascript.. and it'll be something roughly like.. var nowDate = new Date(); document.someTextObject.value = "" + nowDate.getHours() + ":" + nowDate.getMinutes() + ":" + nowDate.getSeconds(); Code (markup): Then on the page you'll have a text input named "someTextObject" or something like that. This should get the time from where the client themselves is and display it in the text object, and then you'll need to run the clock every second to refresh it. I'm not exactly sure how to do that last part, but if you look up 'setTimeout Javascript' you'll find the details about that. I havent actually made one of these myself, but in theory it could recursively call itself. Here's the idea in pseudocode function RefreshClock() clear the timeout for the clock get the new time (this is the code sample above) run RefreshClock() in 1000 milliseconds (this is accomplished via the setTimeout function) Code (markup): This way it sets itself to run in 1 second every time it finishes running. Sorry that I don't have a more developed answer, I've never actually needed something to tick before - but its definitely possible. Good luck!
Dear Akinak ASP works on the server and now() will always show the time on th server end To show the client End time you will need to use Javascript Time Functions
Yeah..but how to keep the time running..It only shows static time. Even if it has to be on the server side, how can I show running time?