$date = new Zend_Date('2021-07-01', 'YYYY-MM-dd'); $date->sub(2, Zend_Date::DAY); echo $date->toString('YYYY-MM-dd'); // Output: 2021-06-29
$date = new Zend_Date('2021-07-01', 'YYYY-MM-dd'); $date->sub(3, Zend_Date::MONTH); echo $date->toString('YYYY-MM-dd'); // Output: 2021-04-01In this example, we use the same approach as the previous example but this time we subtract 3 months from the given date. The output will be ‘2021-04-01’. Package Library: The package library used in the above examples is Zend Framework. Zend_Date is a component of this framework and offers various date and time manipulation functionalities.