I have a requirement to get these dates below in javascript.
I have a drop down with values
Last 15 days
Last month
Last 3 months
Last 6 months
Last 12 months
Now consider if Today's date is Oct 2 2019 and
if i select
Last 15 days
date range i should get is
(Sept 15 '19 - Sept 30 '19)
if i select
Last month
date range i should get is
(Sept 1 '19 - Sept 30 '19 )
if i select
Last 3 months
date range i should get is
(July 1 '19 - Sept 30 '19)
if i select
Last 3 months
date range i should get is
(April 1 '19 - Sept 30 '19)
if i select
Last 12 months
date range i should get is
( Sept 1 '18 - Sept 30 '19)
Now consider if Today's date is Oct 20 2019
if i select
Last 15 days
date range i should get is
(October 1 '19 - Oct 15 '19)
if i select
Last month
date range i should get is
(Sept 1 '19 - Sept 30 '19)
if i select
Last 3 months
date range i should get is
(July 1 '19 - Sept 30 '19)
if i select
Last 3 months
date range i should get is
(April 1 '19 - Sept 30 '19)
if i select
Last 12 months
date range i should get is
(Sept 1 '18 - Sept 30 '19)
Time range can be of database format.
What I have tried:
i am checking with moment js
Managing Dates and Times Using Moment.js[
^] and i am working more on below. If any body can help me to get this work really appreciated. Thank you. I will update here with my outcomes.