I am using getTimezoneOffset() method of javascript and it's giving me the time difference between UTC time and local time, in minutes.For example, If user'stime zone is GMT+2, -120 will be returned.I am passing these minutes to my asp.net c# method:
- How to convert the UTC time saved in my SQL server table to local time according to the upper passing time difference in c# method?
Currently i am using following method to change utc time to user timezone time:
public IHttpActionResult GetProductions(int timeOffset, int quarter)
{
int minutes = 0;
if (timeOffset < 0)
{
minutes = Math.Abs(timeOffset);
}
else
{
minutes = timeOffset * -1;
}
var cullingDatasets = _reportingRepository.GetProductions().ToList().Select(d => new
{
DeliveryDate = d.Delivered.Value.AddMinutes(minutes)
}).ToList();
return Content(HttpStatusCode.OK, cullingDatasets, Configuration.Formatters.JsonFormatter);
}
- If I pass my c# method TimezoneOffset(time get by using getTimezoneOffset() in javascript) and a quarter of the year(like 1st,2nd,3rd, and 4th) then how can I get the array of first dates of all weeks in the given quarter like the following example?
Example: If I open the site from India then I pass from browser timedifferene=-330 and quarter=4 then I need the return from c# method is following array: [05/09,12/09,19/09,26/09,3/10,10/10,17/10,24/10,31/10,7/11,14/11,21/11,28/11,5/12,12/12,19/12,26/12]
Note: I need the first days of the quarter by user timezone by passing the time difference in UTC and local time.