Have had some issues with dates returned from REST services.
Initially I found that the default .net serializer will output the format "Date(\n)\" where n is the number of seconds since 1980 or some such date.
Not sure how everyone else feels about this format but I think its ugly as hell and difficult to debug and work with.
So next I started returned the dates as strings from the WCF REST service.
Best practice seems to be to always deal with UTC in ISO8061.
Here is a small helper method to deal with it.
Date format including time zone
ToISOLocalDate
public static string ToISOLocalDate(DateTime dateTime) { TimeSpan offset = TimeZone.CurrentTimeZone.GetUtcOffset(dateTime); return dateTime.ToString(string.Format("yyyy-MM-ddTHH:mm:ss.00+{0}:{1}", offset.Hours, offset.Minutes == 0 ? "00" : offset.Minutes.ToString())); }
I'm using this class in the services, to return a DateTime which includes the timezone offset.
Date format in UTC
ToIsoDate
public static string ToISODate(DateTime dateTime) { return dateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.00Z"); }
This helper method returns Zulu time.