md-datepicker总是关闭一天
问题描述:
嘿我有一个问题与md-datepicker并且找不到解决方案。 比如我选择2017年5月2日,但我得到2017年5月1日22:00:00md-datepicker总是关闭一天
有我的HTML
<md-input-container flex="50">
<label>test</label>
<md-datepicker ng-model="test.deadline" md-placeholder="Choose date"></md-datepicker>
</md-input-container>
角部位。
$scope.deadline = '';
$scope.$watch('deadline', function(newVal, oldVal) {
if (!newVal) {
return false;
}
});
我将其插入DATEBASE始终有一天下来我知道那是时区的问题,但我不能修复。
我想水木清华这样的
$scope.$watchCollection('deadline', function(newVal, oldVal) {
var test = (moment.utc(newValue.date));
console.log(moment(newValue.date).format('L'), true);
)
};
但得到错误
TypeError: Cannot read property 'utc' of undefined
答
你可以用moment.js做,
$scope.getdate =function(){
console.log($scope.myDate);
$scope.myDate =moment($scope.myDate).format('DD-MMM-YYYY');
}
入住这DEMO
你演示给我:“2017-02- 23T23:00:00.000Z“虽然我选择2017-02-24 –
@RobertNiegowski nope点击按钮获取日期,看看 – Sajeetharan
但我的ng模型是例如ng-model =”test.myDate“我该如何设置它? –