PHP subtract days, months, and years from date example; In this tutorial, i am going to show you how to subtract days, month,s and years from date in PHP.
PHP Subtract Days, Month, Year From Date
Follow the below given examples to subtract days, months, and year to date from PHP:
- PHP Subtract Days to Date
- PHP Subtract Months to Date
- PHP Subtract Year to Date
PHP Subtract Days to Date
Let’s see the below given example for subtract days to date in php; as follows:
<?php $date = "2022-01-10"; $newDate = date('Y-m-d', strtotime($date. ' - 3 days')); echo $newDate; ?>
The output of the above code; as follows:
2022-01-07
PHP Subtract Months to Date
Let’s see the below given example for subtract month to date in php; as follows:
<?php $date = "2022-05-01"; $newDate = date('Y-m-d', strtotime($date. ' - 3 months')); echo $newDate; ?>
The output of the above code; as follows:
2022-02-01
PHP Subtract Year to Date
Let’s see the below given example for subtract year to date in php; as follows:
<?php $date = "2022-02-01"; $newDate = date('Y-m-d', strtotime($date. ' - 5 years')); echo $newDate; ?>
The output of the above code; as follows:
2017-02-01
Recommended PHP Tutorials
Recommended:-How to Connect to phpmyadmin Database in PHP
Recommended:-How to Insert Data Into Database in PHP using Xampp
Recommended:-How to Fetch Single Row Data From Database in PHP
Recommended:-How to Display Data From Database in PHP using Id
Recommended:-How to Update Data From Database in PHP
Recommended:-CRUD Operations in PHP MySQL with Bootstrap
Recommended:-PHP MySQL Ajax Add Edit Delete Same Page
Recommended:-PHP Ajax Live Search From MySQL Database
Recommended:-PHP MySQL Ajax Autocomplete TextBox From DB Example
Recommended:-Form validation using jQuery in PHP
Recommended:-PHP + MySQL Login Form with Session
Recommended:-PHP + MySQL Registration Form with Validation
Recommended:-PHP Ajax Form Submit with Validation Example
Recommended:-Ajax Get Data From MySQL Database in PHP
Recommended:-Google Places Autocomplete in PHP
Recommended:-PHP + MySQL + jQuery Signature Pad
Recommended:-Country State City Dropdown in PHP + MySQL + Ajax
Recommended:-PHP Send Reset Password Link Email
Recommended:-Star Rating System In PHP + MySQL + Ajax
Recommended:-Category Subcategory Dropdown in PHP + MySQL + Ajax
Recommended:-PHP + Ajax Upload Multiple Image with Preview
Recommended:-PHP Upload File to AWS S3 Bucket
Recommended:-Import CSV File Into MySQL Database using PHP
Recommended:-PHP + Ajax Import CSV File Into MySQL Database
Recommended:-PHP + MySQL Login and Registration Form using XAMPP