I'd like to set the time at the top of my site and have it constantly update itself, only client side.
So on the initial page loa开发者_如何转开发d, I'd give it the server time:
[HttpPost]
public ActionResult GetTime()
{
return Content(@DateTime.Now.AddHours(3).ToString("HH:mm"));
//Returns something like: "20:05"
}
Then I'd like the client to just start running a clock starting from the time I've given it.
So when a user loads the page, he recieves 20:05
and without regarding his own local time, I'd like that clock to move forward in a regular fashion. 20:06
, 20:07
, etc.
Is there something like this available for jQuery?
Here's an example of incrementing a number on a page by 1 every second: http://jsfiddle.net/ct3VW/
Is that enough for you to work with?
精彩评论