如果服务器位于另一个国家而不更改服务器时间,如何获取当前国家/地区时间 [英] how to get current country time if the server is in another country with out changing the server time
本文介绍了如果服务器位于另一个国家而不更改服务器时间,如何获取当前国家/地区时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发了一个Web应用程序并将其托管在一个服务器上,但我想为我国以外的不同客户提供相同的产品..
目前我将服务器时间设置为我的国家时间但是如果客户来自国外,系统需要花费他们的国家时间
I developed one web application and I hosted it in one sever but i want to give this same product for different clients outside my country..
Currently i set server time as my country time but if the clients is from outside country the system need to take their country time in
DateTime.Now
我该如何实现?
有可能吗?
How can i implement this?
Is it possible?
推荐答案
这不是一件容易的事,因为你需要知道客户端的本地时区,这意味着使用javascript。但请看这里: http://www.c-sharpcorner.com/uploadfile/vendettamit/setting-your-website-datetime-according-to-time-zone-offset-of-the-client/ [ ^ ]
It's not trivial, because you need to know the local timezone for the client, which means using javascript. But see here: http://www.c-sharpcorner.com/uploadfile/vendettamit/setting-your-website-datetime-according-to-time-zone-offset-of-the-client/[^]
试试这篇文章,这可能会对你有所帮助
http://stackoverflow.com/questions/12735759/how-to-handle-time-zones - 多国语言应用程序中的日期[ ^ ]
Try this article, this may help you
http://stackoverflow.com/questions/12735759/how-to-handle-time-zones-and-dates-in-multi-country-lingual-application[^]
请试试这个我希望它对你有用...... :-)
Please try this one I hope it's working for you......:-)
var dt = DateTime.UtcNow;
var tz = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var localTimeInNewYork = TimeZoneInfo.ConvertTimeFromUtc(dt, tz);
这篇关于如果服务器位于另一个国家而不更改服务器时间,如何获取当前国家/地区时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文