I am having datetime available. All I need to extract date in dd/MM/yyyy and time in hh:mm a format.
I am try below code, but this is not working. What is wrong with the code and How can I achieve the said target?
$scope.date = new Date(dateTimeObj).getDate().toLocaleString("dd/MM/yyyy");
$scope.from = new Date(dateTimeObj).getTime().toLocaleString("hh:mm a");
$scope.to = new Date(dateTimeObj).getTime().toLocaleString("hh:mm a");
edit: I achieved the above functionality using momentjs.
$scope.to moment(dateTimeObj).format("HH:mm A");
Now I'm facing a different problem. This value is not getting binded to the view. Html is as below.
<input type="time" class="form-control" placeholder="To" ng-model="to" id="to" value="{{to}}">
How can I bind the value of time object with HTML5's time control?