Add or Subtract days, month and year to a date using PHP

Today, we write a short tutorial on Add or Subtract days, month and year to a date using PHP.

php subtract minutes from datetime, php subtract days from today, php subtract date from today, php subtract date from current date, how to subtract time in php, php get year from date, php get month from date, Add days to a date, Add month to a date, Add year to a date , Add days to a current date, Add month to a current date, Add year to a current date.

Using php date() and strtotime() function we can easily add or subtract days, month and year to a given date. date() function formats a local date and time and returns the formatted date string.

Add or Subtract days, month and year to a date using PHP

  1. Add days to date
  2. Subtract days from date

Here, we will explain the simple way to do this task with example.

1. Add days to date

The following example shows how to add 7 days to date.

Add 15 days to the current date.

Add 1 month to date.

Add 1 year to date.

2. Subtract days from date

The following example shows how to subtract 5 days from date.

Subtract 2 days from current date.

Subtract 1 month from date.

Subtract 1 year from date.

That’s it for today.
Thank you for reading. Happy Coding!

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *