开发者

How can I get the remote server's date and time at the client side in my application in c#?

I have a cutoff time for user in my application so for this I dont want to take the current system time and instead开发者_运维问答 I want to take the remote server machine's time in to consideration so How can i get the remote servers date and time in c#


Write a request handler on your server that sends the date time. Without more details, its difficult to know how to implement that.


Write a simple web service that when invoked returns the timestamp (possibly using UTC or something).

[WebMethod]
    public string ServerDateTime()
    {
        serverDate = DateTime.UtcNow;
        return serverDate.ToString();
    }

You could be even lazier and have a standard asp.net page that has the same web method as well. Example: http://softwaredevscott.spaces.live.com/blog/cns!1A9E939F7373F3B7!484.entry

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜