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 ;
?>
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!