Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'TimeZoneInfo' does not contain a definition for 'ConvertTimeFromUtc' (DNX Core 5.0)

The code below used to work fine before upgrading to asp5. The method ConvertTimeFromUtc is not supported by DNX Core 5.0. Is there another proper way of achieving this?

public DateTime GmtNow() {
    return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time"));
}
like image 594
Toonsylvania Avatar asked Nov 06 '15 11:11

Toonsylvania


1 Answers

That method doesn't exist any more, I assume it's because the following method covers all options:

TimeZoneInfo.ConvertTime(
    DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time"))
like image 82
DavidG Avatar answered Oct 21 '22 14:10

DavidG