Michael Frizzarin
Michael Frizzarin

Reputation: 3

C# Datetime conversion with the same operation of javascript

Good morning, I have this string format "1444050466000" and if I use javascript I can convert it in a value type date.

Example:

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#?

Upvotes: 0

Views: 51

Answers (1)

Nico
Nico

Reputation: 3542

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)

Upvotes: 1

Related Questions