Reputation: 367
<!-- Date Range - Script -->
<script>
$(function()
{
// Set the default dates
var startDate = Date.create().addDays(-6), // 7 days ago
endDate = Date.create(); // today
var range = $('.range');
// Show the dates in the range input
range.val(startDate.format('{MM}/{dd}/{yyyy}') + ' - ' + endDate.format('{MM}/{dd}/{yyyy}'));
range.daterangepicker
({
startDate: startDate,
endDate: endDate,
ranges:
{
'This Month': [Date.create().addMonths(-1), 'today']
}
}
});
</script>
I am using a sugar.min.js
. I want to get the current month which starts from date 1 to current date.
This This Month': [Date.create().addMonths(-1), 'today']
will give me the date from 04/04/2014 to 05/04/2014. I don't want the previous month date, instead i want this
05/01/2014 to 05/04/2014
Upvotes: 1
Views: 103
Reputation: 4306
A couple of options from sugar's manipulating dates documentation:
Date.create().set({day: 1})
Date.create().beginningOfMonth()
Upvotes: 1