0

I have a UTC time string which I needs to convert in Datetime Object in C#.

I have tried the below sample, but its not working. Can any one help?

long ticks = long.Parse(ateOn);
DateTime ateOnDate = new DateTime(ticks,DateTimeKind.Utc);

where ateOn is UTC time in string.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
Samee Mir
  • 145
  • 1
  • 11

1 Answers1

1
long l = 1360417399227;
var dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
         .Add(TimeSpan.FromMilliseconds(l));
I4V
  • 34,891
  • 6
  • 67
  • 79
  • You got my vote. It would be useful for Samee Mir to explain why you add milliseconds and not seconds (in case of l = 1360417399) as he's confused with datetime ticks and epoch time. –  Feb 09 '13 at 15:11