Get last date or total number of days in PHP

Do you want to find out the last date of the month in PHP. Here is a simple way by providing the valid date. It then takes the month from the date provided and returns the result.

1] Example to find out last date of the date provided

$date = '2016-05-05';
echo date('Y-m-t', strtotime($date));

//output:
2016-05-31


2] Example to find out total number of days of the date provided

$date = '2016-05-05';
echo date('t', strtotime($date));

//output:
31

You can also test with the following dates such as..

$date = 'February'; // Or
$date = 'today'; //Or
$date = "this month"; //..etc.