WCF and Summer Time

Asked

Viewed 212 times

1

I have a date conversion problem in WCF.

I get a Json a Datetime in Unix format

 "\/Date(1477320927000)\/" - 24-10-2016 12:55:27.

Wcf receives this date as 24-10-2016 14:55:27. This giving a difference of 2 hours.

I tried to use TimeZone, CultureInfo, DateTimeKind, DateTimeOffSet, etc.. But nothing worked or puts a 1 to less or 2 hours more.

Someone knows how to fix this?

  • Post the code you’re using..

  • In fact what happens is that the date goes right and it goes wrong in WCF. Basically what I did was: dataReceived.Tolocaltime(); Datetime.Specifykind(dataReceived, Datetimekind.Unspecified)..

  • Is that '1477320927000' is equivalent to '24 Oct 2016 14:55:27', can test here, to test remove the last 3 digits ex: '1477320927',

  • I believe this converter is not validating the Timezone, look at this link. In this is displayed the two forms.

1 answer

1

Try using the following method:

public static DateTime FromUnixTimeMilliseconds(Int64 value)
{
    DateTime dt = new DateTime((value * 10000) + 621355968000000000, DateTimeKind.Utc);
    return dt.ToLocalTime();
}

Output image:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.