title: How to get the hours and minutes from angularjs input-time
body: <p>I know that I have to use the <code>&lt;input type="time".....&gt;</code> to let the user input the time. But I am desperately in a need to know how to use the values of hours and minutes individually for further processing. I am just finding examples everywhere as to how to just accepting and printing the time as a whole(something like object.value). But I currently need to extract the hours and minutes exclusively for my task at hand. Here is by-far the only type of code which I found.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;title&gt;AngularJS Directives : input[time]&lt;/title&gt;
     &lt;script src="angular.js"&gt;&lt;/script&gt;
     &lt;style&gt;
        b{font-family:Papyrus; color:#fa4b2a; font-size: 20px;} 
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body ng-app="timeDemo"&gt;
    &lt;script&gt;
   angular.module('timeDemo', [])
     .controller('timeController', ['$scope', function($scope) {
       $scope.sample = {
         value: new Date(1999, 0, 1, 15, 30, 0)
       };
     }]);
  &lt;/script&gt;
  &lt;form name="demoForm" ng-controller="timeController as timeCtrl"&gt;
     &lt;label for="sampleInput"&gt;Select a time from 6 am to 6 pm&lt;/label&gt;
     &lt;input type="time" id="sampleInput" name="input" ng-model="sample.value"
         placeholder="HH:mm:ss" min="06:00:00" max="18:00:00" required /&gt;
    &lt;!-- min 6 am and max 6 pm i.e 18:00 --&gt;
     &lt;div role="alert"&gt;
       &lt;span class="error" ng-show="demoForm.input.$error.required"&gt;
          Input is Required!&lt;/span&gt;
       &lt;!-- Required Error  --&gt;
       &lt;span class="error" ng-show="demoForm.input.$error.time"&gt;
         Input Date is  not Valid!&lt;/span&gt;
      &lt;!-- Validation Error --&gt;
  
     &lt;/div&gt;
    &lt;i&gt;value = &lt;b&gt;{{sample.value | date: "HH:mm:ss"}}&lt;/b&gt;&lt;/i&gt;&lt;br/&gt;
    &lt;i&gt;demoForm.input.$valid = &lt;b&gt;{{demoForm.input.$valid}}&lt;/b&gt;&lt;/i&gt;&lt;br/&gt;
    &lt;i&gt;demoForm.input.$error = &lt;b&gt;{{demoForm.input.$error}}&lt;/b&gt;&lt;/i&gt;&lt;br/&gt;
    &lt;i&gt;demoForm.$valid = &lt;b&gt;{{demoForm.$valid}}&lt;/b&gt;&lt;/i&gt;&lt;br/&gt;
    &lt;i&gt;demoForm.$error.required = &lt;b&gt;{{!!demoForm.$error.required}}&lt;/b&gt;&lt;/i&gt;&lt;br/&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>