How to get last day of a month from date in PHP ?
Last Updated :
19 May, 2020
Given a date and the task is to print the last day of the month. We will use date() and strtotime() function to get the last day of the month.
Used PHP functions:
Examples:
Input: 2020-04-23
Output: Thursday
Input: '2018-09-11'
Output: Sunday
Approach:
Program:
<?php
$datestring = '2020-04-23' ;
$date = strtotime ( $datestring );
$lastdate = strtotime ( date ( "Y-m-t" , $date ));
$day = date ( "l" , $lastdate );
echo $day ;
?>
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...