Get the last day of a month from date in PHP
Question:
                How to get the last day of a month from date in PHP?            Answer:
                $date = new DateTime($dateStr);
$lastDay = $date->format('Y-m-t');Description:
                To get the last day of a month in PHP simply create a DateTime object first. If you have a DateTime object you can get its formatted value. The format string you need in this case is t which represents the number of days in the given month.
Reference:
                PHP datetime format reference
            Share "How to get the last day of a month from date in PHP?"
                
            Related snippets:
                    - Add minutes to date time in PHP
- Add days to date in PHP
- Get same day in the next week in PHP
- Get time difference in minutes in PHP
- Convert date to timestamp in PHP
- Convert timestamp to DateTime in PHP
- Get the last day of a month from date in PHP
- Get the number of days between two dates in PHP
- Get yesterday's date in PHP
- Get tomorrow's date in PHP
- Get current time in PHP
- Get actual date in PHP
Tags:
                    last day of month, last day, number of days in a month                Technical term:
                    Get the last day of a month from date in PHP