search

Home  >  Q&A  >  body text

angular.js - When angular uses $http post data, why is datetime automatically formatted into UTC? Can it not be formatted?

Figure 1 shows the value of the variable printed before $http is sent;
Figure 2 shows the value captured when $http is sent.

Can I prevent it from automatically converting to UTC and keep 2016-12-15?

天蓬老师天蓬老师2844 days ago617

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 17:12:05

    Thanks for the invitation.

    Your data itself is a time object, but if you want to post, its data format is forced to be converted to the related type of string.

    It is recommended that you format the data into a corresponding string before posting.

    You can use the date built-in filter in angular

    app.controller('myCtrl', function($scope, $filter) {
        console.log($filter('date')(new Date(), 'yyyy-MM-dd'))
    });

    reply
    0
  • Cancelreply