Reputation: 2078
I am trying to figure this strange behaviour on a client machine (IE10)
When we create a new javascript Object, the ajax response from the server is \/Date(-62135596800000)\/
.
I format the JSON Date in the following way:
var date = new moment(parseInt(response.substr(6)));
On the Client machine this Date Object returns the following Date Format 0000-12-31
.
When I try to validate the Date on the Server I get the response is an error saying that this is not a valid date.
My validation is Fluent Validation and the Rule is
RuleFor(x=>x.LastUpdateDate).NotEmpty();
Can anyone point me in the correct direction to help solve this issue?
Upvotes: 0
Views: 212
Reputation: 413895
Your timestamp value is interpreted as being an offset from a fixed UTC reference point. However, when you do something like
alert(theDate)
you'll see the default rendition of the Date instance as it would appear in the local time zone. In other words, a computer in Hong Kong will show the same UTC date differently than a computer in London.
You can use
alert(theDate.toUTCString())
to see a UTC version of the date.
Upvotes: 1