Input date format changing by itself and I don't know why












0















I am writing API for filtering my data. In order to do filtering, I am adding filter inputs to the filter object which is initialized in my angularJs controller.



I am trying to get date value from HTML5 input date element with into that JS object. When I print that filter object, it seems like



{"date":"2018-11-14T21:00:00.000Z"}


But when I print the value of filter object to console,value of the date seems like;



{date: Wed Nov 14 2018 00:00:00 GMT+0300 (GMT+03:00)}


The sample code which is giving the same result with my actual code :



    <html ng-app="MainModule">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>

</head>
<script>
var MainModule = angular
.module("MainModule", )
.controller("MainCtrl", function ($scope) {
$scope.filter = {};
$scope.write = function() {
console.log($scope.filter);
}
});
</script>

<body ng-controller="MainCtrl">
<input type="text" ng-model="ali"> {{ali}}
<input type="date" ng-model="filter.date">
{{filter}}
<button ng-click="write()">Write</button>
</body>


</html>


I am using Chrome browser but I tried to send filter object to the backend with Firefox but sended date value was same with Chrome's. How can I prevent my date value to be changed?










share|improve this question























  • Note the Z postfix denotes Zulu time, which is equivalent to GMT+00:00. If I ran your snippet locally (I'm in GMT+08:00), I see Wed Nov 14 2018 00:00:00 GMT+0800 logged to the console and 2018-11-13T16:00:00.000Z in the HTML. These times are effectively equivalent.

    – miqh
    Nov 13 '18 at 23:41











  • Understood. Do you know how can I prevent my raw date data value to be changed? I want it to stay like "2018-11-14T21:00:00.000Z"

    – safaer
    Nov 13 '18 at 23:43











  • How are you sending $scope.filter to the server? If you're calling JSON.stringify() to serialise the data beforehand (like so—plnkr.co/edit/FdNrK5jtTYfYBe5xkNKi) the Date value should be in the Zulu time form.

    – miqh
    Nov 13 '18 at 23:53











  • I have other filter elements in filter object (like name, surname etc). I am sending it to server without doing any operations. E.g data: $scope.filter

    – safaer
    Nov 14 '18 at 0:00











  • Note that the console is not a reliable way of determining what the stringified version of an object is. You should call toString explicitly (e.g. here on SO console.log(date) is equivalent to date.toISOString() but in most browser consoles you'll get date.toString(), which is very different.

    – RobG
    Nov 14 '18 at 1:31


















0















I am writing API for filtering my data. In order to do filtering, I am adding filter inputs to the filter object which is initialized in my angularJs controller.



I am trying to get date value from HTML5 input date element with into that JS object. When I print that filter object, it seems like



{"date":"2018-11-14T21:00:00.000Z"}


But when I print the value of filter object to console,value of the date seems like;



{date: Wed Nov 14 2018 00:00:00 GMT+0300 (GMT+03:00)}


The sample code which is giving the same result with my actual code :



    <html ng-app="MainModule">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>

</head>
<script>
var MainModule = angular
.module("MainModule", )
.controller("MainCtrl", function ($scope) {
$scope.filter = {};
$scope.write = function() {
console.log($scope.filter);
}
});
</script>

<body ng-controller="MainCtrl">
<input type="text" ng-model="ali"> {{ali}}
<input type="date" ng-model="filter.date">
{{filter}}
<button ng-click="write()">Write</button>
</body>


</html>


I am using Chrome browser but I tried to send filter object to the backend with Firefox but sended date value was same with Chrome's. How can I prevent my date value to be changed?










share|improve this question























  • Note the Z postfix denotes Zulu time, which is equivalent to GMT+00:00. If I ran your snippet locally (I'm in GMT+08:00), I see Wed Nov 14 2018 00:00:00 GMT+0800 logged to the console and 2018-11-13T16:00:00.000Z in the HTML. These times are effectively equivalent.

    – miqh
    Nov 13 '18 at 23:41











  • Understood. Do you know how can I prevent my raw date data value to be changed? I want it to stay like "2018-11-14T21:00:00.000Z"

    – safaer
    Nov 13 '18 at 23:43











  • How are you sending $scope.filter to the server? If you're calling JSON.stringify() to serialise the data beforehand (like so—plnkr.co/edit/FdNrK5jtTYfYBe5xkNKi) the Date value should be in the Zulu time form.

    – miqh
    Nov 13 '18 at 23:53











  • I have other filter elements in filter object (like name, surname etc). I am sending it to server without doing any operations. E.g data: $scope.filter

    – safaer
    Nov 14 '18 at 0:00











  • Note that the console is not a reliable way of determining what the stringified version of an object is. You should call toString explicitly (e.g. here on SO console.log(date) is equivalent to date.toISOString() but in most browser consoles you'll get date.toString(), which is very different.

    – RobG
    Nov 14 '18 at 1:31
















0












0








0








I am writing API for filtering my data. In order to do filtering, I am adding filter inputs to the filter object which is initialized in my angularJs controller.



I am trying to get date value from HTML5 input date element with into that JS object. When I print that filter object, it seems like



{"date":"2018-11-14T21:00:00.000Z"}


But when I print the value of filter object to console,value of the date seems like;



{date: Wed Nov 14 2018 00:00:00 GMT+0300 (GMT+03:00)}


The sample code which is giving the same result with my actual code :



    <html ng-app="MainModule">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>

</head>
<script>
var MainModule = angular
.module("MainModule", )
.controller("MainCtrl", function ($scope) {
$scope.filter = {};
$scope.write = function() {
console.log($scope.filter);
}
});
</script>

<body ng-controller="MainCtrl">
<input type="text" ng-model="ali"> {{ali}}
<input type="date" ng-model="filter.date">
{{filter}}
<button ng-click="write()">Write</button>
</body>


</html>


I am using Chrome browser but I tried to send filter object to the backend with Firefox but sended date value was same with Chrome's. How can I prevent my date value to be changed?










share|improve this question














I am writing API for filtering my data. In order to do filtering, I am adding filter inputs to the filter object which is initialized in my angularJs controller.



I am trying to get date value from HTML5 input date element with into that JS object. When I print that filter object, it seems like



{"date":"2018-11-14T21:00:00.000Z"}


But when I print the value of filter object to console,value of the date seems like;



{date: Wed Nov 14 2018 00:00:00 GMT+0300 (GMT+03:00)}


The sample code which is giving the same result with my actual code :



    <html ng-app="MainModule">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>

</head>
<script>
var MainModule = angular
.module("MainModule", )
.controller("MainCtrl", function ($scope) {
$scope.filter = {};
$scope.write = function() {
console.log($scope.filter);
}
});
</script>

<body ng-controller="MainCtrl">
<input type="text" ng-model="ali"> {{ali}}
<input type="date" ng-model="filter.date">
{{filter}}
<button ng-click="write()">Write</button>
</body>


</html>


I am using Chrome browser but I tried to send filter object to the backend with Firefox but sended date value was same with Chrome's. How can I prevent my date value to be changed?







javascript angularjs html5 date






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 23:27









safaersafaer

216




216













  • Note the Z postfix denotes Zulu time, which is equivalent to GMT+00:00. If I ran your snippet locally (I'm in GMT+08:00), I see Wed Nov 14 2018 00:00:00 GMT+0800 logged to the console and 2018-11-13T16:00:00.000Z in the HTML. These times are effectively equivalent.

    – miqh
    Nov 13 '18 at 23:41











  • Understood. Do you know how can I prevent my raw date data value to be changed? I want it to stay like "2018-11-14T21:00:00.000Z"

    – safaer
    Nov 13 '18 at 23:43











  • How are you sending $scope.filter to the server? If you're calling JSON.stringify() to serialise the data beforehand (like so—plnkr.co/edit/FdNrK5jtTYfYBe5xkNKi) the Date value should be in the Zulu time form.

    – miqh
    Nov 13 '18 at 23:53











  • I have other filter elements in filter object (like name, surname etc). I am sending it to server without doing any operations. E.g data: $scope.filter

    – safaer
    Nov 14 '18 at 0:00











  • Note that the console is not a reliable way of determining what the stringified version of an object is. You should call toString explicitly (e.g. here on SO console.log(date) is equivalent to date.toISOString() but in most browser consoles you'll get date.toString(), which is very different.

    – RobG
    Nov 14 '18 at 1:31





















  • Note the Z postfix denotes Zulu time, which is equivalent to GMT+00:00. If I ran your snippet locally (I'm in GMT+08:00), I see Wed Nov 14 2018 00:00:00 GMT+0800 logged to the console and 2018-11-13T16:00:00.000Z in the HTML. These times are effectively equivalent.

    – miqh
    Nov 13 '18 at 23:41











  • Understood. Do you know how can I prevent my raw date data value to be changed? I want it to stay like "2018-11-14T21:00:00.000Z"

    – safaer
    Nov 13 '18 at 23:43











  • How are you sending $scope.filter to the server? If you're calling JSON.stringify() to serialise the data beforehand (like so—plnkr.co/edit/FdNrK5jtTYfYBe5xkNKi) the Date value should be in the Zulu time form.

    – miqh
    Nov 13 '18 at 23:53











  • I have other filter elements in filter object (like name, surname etc). I am sending it to server without doing any operations. E.g data: $scope.filter

    – safaer
    Nov 14 '18 at 0:00











  • Note that the console is not a reliable way of determining what the stringified version of an object is. You should call toString explicitly (e.g. here on SO console.log(date) is equivalent to date.toISOString() but in most browser consoles you'll get date.toString(), which is very different.

    – RobG
    Nov 14 '18 at 1:31



















Note the Z postfix denotes Zulu time, which is equivalent to GMT+00:00. If I ran your snippet locally (I'm in GMT+08:00), I see Wed Nov 14 2018 00:00:00 GMT+0800 logged to the console and 2018-11-13T16:00:00.000Z in the HTML. These times are effectively equivalent.

– miqh
Nov 13 '18 at 23:41





Note the Z postfix denotes Zulu time, which is equivalent to GMT+00:00. If I ran your snippet locally (I'm in GMT+08:00), I see Wed Nov 14 2018 00:00:00 GMT+0800 logged to the console and 2018-11-13T16:00:00.000Z in the HTML. These times are effectively equivalent.

– miqh
Nov 13 '18 at 23:41













Understood. Do you know how can I prevent my raw date data value to be changed? I want it to stay like "2018-11-14T21:00:00.000Z"

– safaer
Nov 13 '18 at 23:43





Understood. Do you know how can I prevent my raw date data value to be changed? I want it to stay like "2018-11-14T21:00:00.000Z"

– safaer
Nov 13 '18 at 23:43













How are you sending $scope.filter to the server? If you're calling JSON.stringify() to serialise the data beforehand (like so—plnkr.co/edit/FdNrK5jtTYfYBe5xkNKi) the Date value should be in the Zulu time form.

– miqh
Nov 13 '18 at 23:53





How are you sending $scope.filter to the server? If you're calling JSON.stringify() to serialise the data beforehand (like so—plnkr.co/edit/FdNrK5jtTYfYBe5xkNKi) the Date value should be in the Zulu time form.

– miqh
Nov 13 '18 at 23:53













I have other filter elements in filter object (like name, surname etc). I am sending it to server without doing any operations. E.g data: $scope.filter

– safaer
Nov 14 '18 at 0:00





I have other filter elements in filter object (like name, surname etc). I am sending it to server without doing any operations. E.g data: $scope.filter

– safaer
Nov 14 '18 at 0:00













Note that the console is not a reliable way of determining what the stringified version of an object is. You should call toString explicitly (e.g. here on SO console.log(date) is equivalent to date.toISOString() but in most browser consoles you'll get date.toString(), which is very different.

– RobG
Nov 14 '18 at 1:31







Note that the console is not a reliable way of determining what the stringified version of an object is. You should call toString explicitly (e.g. here on SO console.log(date) is equivalent to date.toISOString() but in most browser consoles you'll get date.toString(), which is very different.

– RobG
Nov 14 '18 at 1:31














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291008%2finput-date-format-changing-by-itself-and-i-dont-know-why%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291008%2finput-date-format-changing-by-itself-and-i-dont-know-why%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python