Question: How do we get a date before the current date using DayJs.

I know how to get the current date but can we like remove 15 days from the current date?

```
cy.get('input[name="day"]').should('have.value', (Cypress.dayjs().format('DD')))
cy.get('input[name="month"]').should('have.value', (Cypress.dayjs().format('MM')))
 cy.get('input[name="year"]').should('have.value', (Cypress.dayjs().format('YY'))) ```

This is my code for getting the currentDate. I would like to get 15 days before my current Date. I would have used substract if the date was one input field but here we have different placeholders for the inputs.

```

Answer: 
From the [documentation](https://day.js.org/docs/en/manipulate/subtract):

```js
dayjs().subtract(15, 'day');

```

Available units are mentioned [here](https://day.js.org/docs/en/manipulate/add#list-of-all-available-units), `day` is one of them.
As @pavelsaman mentioned `.subtract` will work. Yo just have to format it to extract day, month, year.

```js
const dayjs = require('dayjs')

cy.get('input[name="day"]').should(
  'have.value',
  dayjs().subtract(15, 'day').format('DD')
) //11
cy.get('input[name="month"]').should(
  'have.value',
  dayjs().subtract(15, 'day').format('MM')
) //10
cy.get('input[name="year"]').should(
  'have.value',
  dayjs().subtract(15, 'day').format('YY')
) //21

```