Michael Frizzarin Michael Frizzarin - 8 months ago 58
C# Question

C# Datetime conversion with the same operation of javascript

Good morning,
I have this string format

and if I use javascript I can convert it in a value type date.


var b = "1444050466000";
var isoDate = new Date(b).toISOString('yyyy-MM-dd HH:mm:ss Z');

result: 2015-10-05T13:07:46.000Z

My question is, there is a way to do the same conversion in C#?


You could create a base DateTime representing a Unix Timestamp (1.1.1970 UTC) and add the milliseconds: new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(1444050466000)