Is there anyway to change the default JSON serialization/deserialization of DateTime in WCF?
Currently, DateTime are serialized into the /Date(1372252162657+0200)/
format, which should've been fine but I'm running into issues when my server is not in UTC (which I can't change).
All date/time data that is being processed by this service is in UTC format. Everything works when the server is in UTC. However, the staging/prod environments are set to GMT+1(Paris) and the serializer is assuming that the dates/times are in GMT+1, completely ignoring the attribute Kind
. So as you'd expect calling DateTime.SetKind()
and setting it to UTC will not work. In effect, the serialized times are delayed by an hour.
I can either do two-way date conversations (it also makes the same assumption when deserializing so its always GMT+1) conversation of dates: UTC to/from server time, but this is to tedious. So I thought maybe I could just override the default serialization behavior.