考虑:
var myDate = $scope.today;
var previousDay = new Date(myDate);
previousDay.setDate(myDate.getDate() - 1);
var date = previousDay; // 2017-03-04 09:46:22.103 +5.30 GMT
我如何才能获得“2017-03-03 09:46:22.103”?
答案 0 :(得分:1)
您可以使用
var requiredDateFormat = previousDay.toLocaleDateString() + " " + previousDay.toLocaleTimeString();
答案 1 :(得分:0)
您可以使用new Date().toJSON();
。它将返回"2017-03-04T04:55:50.786Z"
。