quma
quma

Reputation: 5753

angularJS $http datetime is changed

I use AngularJS for my appl and also the $http- provider. I have a problem with the dateTime. I create da date with javaScript (var date = new Date() e.g. 2016-03-09 00:00) and if I will send this date (in object ParameterObject) to backend over $http one hour is subtract (2016-03-08 23:00+01:00). I will prevent this. Does anyone know how, is there e.g. a flag for $http?

return $http.post(baseURL + '/restServiceURL/', ParameterObject).success(function(data) {...

Upvotes: 1

Views: 60

Answers (1)

Python Basketball
Python Basketball

Reputation: 2370

you need to add the following code to your js:

Date.prototype.toJSON = function () { return this.toLocaleString(); }

Upvotes: 2

Related Questions