How to set the date in the Angular Date Range Picker to the 1st day of the month

AlexFF1 picture AlexFF1 · Jun 23, 2015 · Viewed 8.6k times · Source

Im using this Angular directive for date range picker

https://github.com/g00fy-/angular-datepicker

At the moment is sets the default date to current date

How can I set the first date range to be 1st day of the month. How to set the date?

<div date-range start="a" end="b"> </div>

{{(a|date)||"pick start"}} {{(b|date)||"pick end"}}

Answer

Pankaj Parkar picture Pankaj Parkar · Jun 23, 2015

You could use

var date = new Date();
$scope.a = new Date(date.getFullYear(), date.getMonth(), 1);
$scope.b = new Date(date.getFullYear(), date.getMonth() + 1, 0);