I have following text input filled by model value in timestamp:
You can also specify a timezone like this:
$scope.$watch('workerDetail.dateOfBirth', function (newDate) {
$scope.workerDetail.dateOfBirth = $filter('date')(newDate, 'HH:mm', 'UTC');
});
You can try a filter
HTML
<input type="datetime" ng-model="mydateOfBirth" class="form-control" id="date_of_birth" />
Controller JS
$scope.$watch('mydateOfBirth', function (newValue) {
$scope.workerDetail.dateOfBirth = $filter('date')(newValue, 'yyyy/MM/dd');
});
$scope.$watch('workerDetail.dateOfBirth', function (newValue) {
$scope.mydateOfBirth = $filter('date')(newValue, 'yyyy/MM/dd');
});
Try This code to Get a date Only (dd/mm/yyyy)
html
<div class="col-lg-3">
<input type="date" name="dob" class="input-lg form-group" ng-model='dob'>
</div>
Angularjs
app.controller('myctrl',function($scope, $http,$window,$filter) {
$scope.sent=function(){
$scope.date = $filter("date")($scope.dob, 'dd-MM-yyyy');
alert($scope.date);
}})