0

i am newbie in angularjs..

This is my form field:

input type="time" ng-model=mytime

The input type time gives me HH:MM: PM/AM from the above syntax.

I want to get the value of the field one by one using angular js. how do I get my HH value using angular js ??

Also is there any way to integrate camera plugin using angularjs?

Please help.

0

2 Answers 2

1

In AngularJS, use the date filter to control the presentation of the date.

<input type="date" ng-model="mytime">
<input type="time" ng-model="mytime"><br>

{{mytime | date : 'd MMM yyyy hh:mm:ss'}}

For more information, see AngularJS date Filter API Reference.


For type="date" and type="time" inputs, ng-model returns a JavaScript Date object. All the standard Date methods are available.

var hours = $scope.mytime.getHours();
var month = $scope.mytime.getMonth();

// etc.

For more information, see MDN JavaScript Reference - Standard Objects - Date.

Sign up to request clarification or add additional context in comments.

1 Comment

Nice to notice that ng-model for both date and time has the same value.
0

You could use split which will split a string into an array of substrings based on a separator. The hours will then be the first item in the array. You can do this like so:

var hours = $scope.mytime.split(';')[0];

3 Comments

Please explain how your answer solves the problem, it will help everyone understand your solution with more clarity and for future reference.
Thu Jan 01 1970 13:03:00 GMT+0530 (IST) this is inserted in the table.
how do i get hours and mins from the Sun Apr 03 2016 18:28:10 GMT+0530 (IST) and set it to my html input type time..? as i m getting an error of datefmt..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.