Edm.DateTime "Invalid date/time value": No "Z" in date/time

May 7, 2013 at 1:07 PM
Edited May 7, 2013 at 1:08 PM

My client crashes (datajs-1.1.0) with an "Invalid date/time value". Using Fiddler I get the following:
Looking a datajs it seems like a "Z" is expected in my date/time value:
if (!parts || (!withOffset && offset !== "Z")) {
    if (nullOnError) {
        return null;
    throw { message: "Invalid date/time value" };
What do I have do change on my server in order to get the correct format? (I'm using OData with WebAPI)

Sep 22, 2013 at 7:38 PM
I'm seeing the exact same thing, only I'm using WCF Data Services. The Edm.DateTime fields that are coming back do not contain a "Z". Is this a compatibility problem? I'm running datajs-1.1.1 and whatever comes out of the box in Visual Studio 2012 with WCF Data Services... and I just discovered that there are later versions of the WCF Data Services libraries available on nuget and that's probably why I'm seeing this error... However, I just installed the 5.6.0 libraries and I'm still getting the same error. Any idea of what's going on? Is there a config setting I'm missing?
Sep 23, 2013 at 5:18 PM
So I was only seeing this error when posting a new item. I had a ChangeInterceptor on my data service that added a datestamp using 'DateTime.Now'. Eventuall, I discovered that I needed to specify a datetime kind since it was serializing my datestamp as a local date with an offset. Doing the following inside my ChangeInterceptor solved the issue for me:
post.DateCreated = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);