Angularjs仅在php中从html输入时间属性输出时间


Angularjs output time only in php from html input time attribute

我想通过Angularjs将"时间"属性的值从HTML保存到PHP。

在我的HTML中,我有:

<input type="time" ng:model="stime.val" ng:value="stime.val | date: 'HH:mm:ss'" >

在控制器中:

$scope.stime = { val: new Date(1970, 0, 1, 09, 00, 00) };
$scope.sendtime = [{ 'time'  : $scope.stime }];
http({ method: 'POST', url: '../index.php',
       data : $.param({ 'sendTime' : $scope.sendtime, 
                        'type' : 'post_time'
                }),
       headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success( cut off code...

在PHP中:

header("Content-Type: application/json; charset=utf-8");
$postResponse = file_get_contents("php://input");
json_decode($postResponse);
if($_POST['type'] == 'post_time')
    { 
       $startTime = $_POST['sendTime']['val']; 
       print_r($startTime); 
    }

返回的数据是(假设我输入"15:06:04")

Tue Dec 01 2015 15:06:04 GMT+0000 (GMT Standard Time)

我的问题是,我如何才能从HTML中返回时间?

像这样的。。

15:06:04

您可以通过以下方式在控制器中使用相同的过滤器:

console.log( $filter('date')( $scope.stime.val, 'HH:mm:ss' ) );