Javascript 使用Angular js从datetime提取时间

Javascript 使用Angular js从datetime提取时间,javascript,datetime,angularjs,angularjs-directive,Javascript,Datetime,Angularjs,Angularjs Directive,我需要使用Angular js从datetime(例如:2013-09-03 05:02:04)提取小时和分钟 JSON数据: { "status": "success", "data": [ { "PriorityPassReservation": { "site_id": "8", "id": "235907", "priority_pass

我需要使用Angular js从datetime(例如:2013-09-03 05:02:04)提取小时和分钟

JSON数据:

{
    "status": "success",
    "data": [
        {
            "PriorityPassReservation": {
                "site_id": "8",
                "id": "235907",
                "priority_pass_schedule_id": "4",
                "member_id": null,
                "member_guid": "8-853414",
                "reservation_dt": "2013-09-05 19:00:00",
                "checkin_dt": null,
                "reminder_sent": "0",
                "created": "2013-09-03 05:02:04",
                "modified": "2013-09-03 05:02:04",
                "status": "booked"
            }
]
}
HTML:


{{$index+1}}
{{priority.PriorityPassReservation.reservation| date:'hh:mm'}}
但它没有给出实际的结果。有人知道解决方案吗


注意:
priority.PriorityPassReservation.reservation是一个json字符串

Time-05:02:04(0-24格式)。尝试使用“hh:mm”。或者使用时间格式2010年10月29日上午8:40:23(带AM)。

时间-05:02:04(0-24格式)。尝试使用“hh:mm”。或者使用时间格式2010年10月29日上午8:40:23(带AM)。

我认为问题可能与仅支持符合ISO8601标准的日期字符串格式的角度日期过滤器有关。 您可以简单地将日期字符串转换为日期对象

<td class="priority_time">
    {{getDateObject(priority.PriorityPassReservation.reservation_dt) | 
    date:' h:mm'}}
</td>

我认为问题可能与仅支持符合ISO8601标准的日期字符串格式的angular日期过滤器有关。 您可以简单地将日期字符串转换为日期对象

<td class="priority_time">
    {{getDateObject(priority.PriorityPassReservation.reservation_dt) | 
    date:' h:mm'}}
</td>

谢谢你的回复。但是它不起作用。实际上priority.PriorityPassReservation.reservation\u dt是一个json字符串谢谢你的回复。但是它不起作用。实际上priority.PriorityPassReservation.reservation\u dt是一个json字符串。你有没有尝试过angular.fromJson将其转换为反序列化字符串?@David Chase没有。我没有这样做。更新了我的问题您的问题是因为您已经有了日期和时间筛选器无法处理您的值,请尝试仅使用带有“:”的字符串将引发意外的令牌错误您是否尝试过angular.fromJson将其转换为反序列化字符串?@David Chase no..我不喜欢这样做。更新了我的问题您的问题是因为您已经有了日期和时间筛选器无法处理您的值,请尝试仅使用带有“:”的字符串将抛出意外的令牌错误Thank Code Hater..希望它能工作,但是如何动态转换日期object@Gopesh您可以通过拆分字符串并将其传递给
Date
构造函数来提取y、m、d、h、m、s。此任务的常用库为。它可以为你解析日期,还有更多!谢谢代码仇恨者。希望它能工作,但是我如何动态转换日期呢object@Gopesh您可以通过拆分字符串并将其传递给
Date
构造函数来提取y、m、d、h、m、s。此任务的常用库为。它可以为你解析日期,还有更多!
$scope.getDateObject = function(dt){
    /* convert to date object */
    /* return new Date(2013,8,3,5,2,4); */
}