i want to add one day to the current date heres my code :
var dt = $filter('date')(new Date(), "yyyy-MM-dd");
alert(dt);
dt.setDate(dt.getDate() + 1);
alert("date plus one day is : "+dt);
thats gave me an error:
TypeError: dt.getDate is not a function
can anybody help please??
Add one day to date before the filter.
var sdate = new Date();
sdate.setDate(sdate.getDate() + 1);
var dt = $filter('date')(sdate, "yyyy-MM-dd");
angular.module("app",[])
.controller("ctrl",function($scope,$filter){
var sdate = new Date();
alert(sdate);
sdate.setDate(sdate.getDate() + 1);
var dt = $filter('date')(sdate, "yyyy-MM-dd");
alert("date plus one day is : "+dt);
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
</div>
If you are open to using Moment.js you can use -
moment().add(1, 'days')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With