Prism · Time

$dateAdd

Moves a date by an amount of a unit. A negative amount moves it back.

The source
{ createdAt: '2024-01-15T08:30:00Z' }
The config
{
  $date: {
    value: {
      $dateAdd: {
        date: { $ref: '$.createdAt' },
        amount: 30,
        unit: 'day',
      },
    },
    format: 'YYYY-MM-DD',
  },
}
What comes out
'2024-02-14'
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.