1、angular中我们自己设置的时间filter
//获取时间转换成指定样式的filter
//其他时间样式---->制定时间样式app.filter('formatDatefilter', function() {
return function(input) {
var date = new Date(input);
Y = date.getFullYear() + '-';
M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
D = date.getDate() + ' ';
//formatDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
var formatDate = Y + M + D;
return formatDate;
}
});
2、对页面<input type='date' /> 输入的日期进行转换
/**
* 出生年月时间
*/
var birthdayTime = new Date($scope.birthday).getTime();// 将标准时间转为时间戳
console.log(birthdayTime);
var birthdayDate = new Date(birthdayTime);
Y = birthdayDate.getFullYear() + '-';
M = (birthdayDate.getMonth() + 1 < 10 ? '0' + (birthdayDate.getMonth() + 1) : birthdayDate.getMonth() + 1) + '-';
D = birthdayDate.getDate() + ' ';
var birthdayParam = Y + M + D;
console.log(birthdayParam);