Created
March 10, 2020 16:59
-
-
Save shreesubhendu/f9ada64f165fc69c0786339d59d2c79f to your computer and use it in GitHub Desktop.
Last day of given month and year and last day of previous month in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$current_month = 3; | |
$current_year = 2020; | |
//first day of previous month from given month and year | |
$firstDayOfLastMonth = date_create($current_year.'-'.$current_month.'-01 first day of last month')->format('Y-m-d'); | |
//last day of previous month from given month and year | |
$lastDayOfLastMonth = date_create($current_year.'-'.$current_month.'-01 last day of last month')->format('Y-m-d'); | |
//first day of given month and year | |
$firstDayOfCurrentMonth = date("Y-m-d",strtotime($current_year.'-'.$current_month.'-01')); | |
//last day of given month and year | |
$lastDayOfCurrentMonth = date("Y-m-t",strtotime($current_year.'-'.$current_month.'-01')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment