To get previous day, month, year form given date in PHP; Through this tutorial, i am going to show you how to get previous day, month, year from given date in PHP.
How to Get Previous Day, Month, Year From Date In Php
- How to Get Previous Day From Given Date In Php?
- How to Get Previous Month From Given Date In Php?
- How to Get Previous Year From Given Date In Php?
How to Get Previous Day From Given Date In Php?
Using the php date() and strtotime() function, you can get previous day from date in php; let’s see the following example:
<?php $date = "2022-01-11"; $newdate = date("Y-m-d",strtotime ( '-1 day' , strtotime ( $date ) )) ; echo $newdate; ?>
Output of the above code; is as follows:
2022-01-10
How to Get Previous Month From Given Date In Php?
Using the php date() and strtotime() function, you can get previous month from date in php; let’s see the following example:
<?php $date = "2022-02-11"; $newdate = date("Y-m-d", strtotime ( '-1 month' , strtotime ( $date ) )) ; echo $newdate; ?>
Output of the above code; is as follows:
2022-01-11
How to Get Previous Year From Given Date In Php?
Using the php date() and strtotime() function, you can get previous year from date in php; let’s see the following example:
<?php $date = "2022-01-11"; $newdate = date("Y-m-d",strtotime ( '-1 year' , strtotime ( $date ) )) ; echo $newdate; ?>
Output of the above code; is as follows:
2021-01-11
Recommended PHP Tutorials
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
Recommended:-Import json File Data Into MySQL Database in PHP
Recommended:-PHP Subtract Days, Month, Year From Date
Recommended:-PHP Add Days, Month, Year From Date
Recommended:-How to change max file upload size in php ini Ubuntu