Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert UTC DateTime to specific time zone xamarin forms pcl

I am working on a project in which i am getting UTC DateTime in service response. I am trying to convert UTC DateTime to Datetime in specific time zone. i have tried System.TimeZoneInfo.ConvertTimeBySystemTimeZoneId but it is unavailable in xamarin forms pcl.

Is there any solution or workaround to handle this scenario?

Thanks

like image 522
Sunny Avatar asked Oct 11 '17 08:10

Sunny


People also ask

How do you convert UTC to specific time zones?

(GMT-5:00) Eastern Time (US & Canada)Add the local time offset to the UTC time. For example, if your local time offset is -5:00, and if the UTC time is shown as 11:00, add -5 to 11. The time setting when adjusted for offset is 06:00 (6:00 A.M.).


1 Answers

Try to use ToLocalDateTime() this way:

DateTime date = DateTime.Now;
var test = date.ToLocalDateTime();
like image 142
Diego Rafael Souza Avatar answered Sep 19 '22 21:09

Diego Rafael Souza