Я хочу сохранить с HTML на PHP через Angularjs значение атрибута "time".
В моем 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' ) );