-1

I need to convert a utc datetime to a local datetime.

it should look something like this:

private DateTime localdate (DateTime UTC_DateTime)
{

DateTime local =  new DateTime();
local  = UTC_DateTime .....         ??? 

return local;

}

Thanks in advance for your Help!

Soner Gönül
  • 94,086
  • 102
  • 195
  • 339
Eray Geveci
  • 1,089
  • 4
  • 17
  • 37

2 Answers2

1

Do it like so:

private DateTime Localdate (DateTime utc_DateTime)
{

    DateTime local =  new DateTime();
    local  = utc_DateTime.ToLocalTime();

    return local;

 }

But the method itself is "a bit" redundant. Just a recommendation: Try to respect the "Pascal-case convention" embraced by C# which states that method names are capitalized and that parameter names are not (amongst other things).

Eduard Dumitru
  • 3,154
  • 16
  • 30
0

use method DateTime.ToLocalTime()

burning_LEGION
  • 12,864
  • 8
  • 38
  • 50