I
I
Igor Braduloff2018-09-19 16:50:34
Yii
Igor Braduloff, 2018-09-19 16:50:34

How to change Last 7 days selection to Last Week in DateRangePicker?

Good afternoon! DateRangePicker has presets and one of them is 'Last 7 days'. I need to change it to Last Week and the selection, respectively.
5ba25419b6eda943605033.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2018-09-19
@kawabanga

or kartik? And open the documentation, on the first page there is an answer
demos.krajee.com/date-range
Next, google last week in moment js , and generate a picker template.

initRangeExpr = true;
pluginOptions['ranges'] = [
    Yii::t('kvdrp', 'Today') => ["moment().startOf('day')", "moment().endOf('day')"],
    Yii::t('kvdrp', 'Yesterday') => ["moment().startOf('day').subtract(1,'days')", "moment().endOf('day').subtract(1,'days')"],
    Yii::t('kvdrp', 'Last {n} Days', ['n' => 7]) => ["moment().startOf('day').subtract(6, 'days')", "moment().endOf('day')"],
    Yii::t('kvdrp', 'Last {n} Days', ['n' => 30]) => ["moment().startOf('day').subtract(29, 'days')", "moment().endOf('day')"],
    Yii::t('kvdrp', 'This Month') => ["moment().startOf('month')", "moment().endOf('month')"],
    Yii::t('kvdrp', 'Last Month') => ["moment().subtract(1, 'month').startOf('month')", "moment().subtract(1, 'month').endOf('month')"]
];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question