Xamarin表格:如何从当前设备时间更改为其他国家/地区时间 [英] Xamarin Form: How do i change from current device time to different country time
问题描述
我对日期时间不太熟悉。目前,我不知道如何将设备的现有时间转换为其他国家/地区的日期/时间。
I am not too familiar with date time. I am currently wonder how can I convert the existing time of the device to a different countries' date/time.
例如App.CurrentDate<-显示设备设置日期/时间。我希望在选择可以在任何国家/地区使用的其他网站时出现在不同国家/地区的时间
E.g. App.CurrentDate <- which display the device setting date/time. I want it to be in different country's time when choosing different site where the site can be any countries
有可能实现这一目标吗?
Is it possible to achieve this?
推荐答案
Android和iOS使用IANA时区名称。它们看起来像美国/纽约,您可以在 tz数据库时间的列表中找到它们的列表。
Android and iOS use IANA timezone names. They look like this "America/New_York" and you can find a list of them at the List of tz database time zones.
TimeZoneInfo estZone = TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
DateTime estTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, estZone);
参考:
1 http://www.xamarinhelp.com/time-zones-xamarin-forms/
2 https://help.syncfusion.com/xamarin / scheduler / timezone
这篇关于Xamarin表格:如何从当前设备时间更改为其他国家/地区时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!