使用角度日期过滤器转换Bootstrap Datepicker日期

时间:2015-10-19 19:08:19

标签: angularjs bootstrap-datetimepicker

我的datepicker返回了以下日期:

Date {Thu Oct 22 2015 00:00:00 GMT+0000 (GMT Standard Time)}

我正在尝试使用angularjs的$ filter来按照我想要的方式对其进行格式化,但它似乎没有用,有没有办法解决这个问题?:

 $filter('date')(new Date($scope.form.date + ' ' + ticket.departure_time, "mediumDate"));

2 个答案:

答案 0 :(得分:0)

您需要使用date formatting stringsDate对象转换为所需的格式。 Here's如何使用Angular的$ filter:

$filter('date')(new Date($scope.form.date), 'mediumDate');

答案 1 :(得分:0)

完成下载和集成DateJS。然后我这样做是为了达到我想要的目的:

var ticket_date =  Date.parse($scope.form.date).toString('MMM dd, yyyy');
var ticket_time = Date.parse(ticket.departure_time).toString('hh:mm tt');
相关问题