How to get last day of the month using php ?
<?php
echo date('?-?-?');
?>
try this
$day=date('Y-m-t'); // gives last day of current month
OR
$d = new DateTime( '2013-05-03' );
echo $d->format( 'Y-m-t' );
<?php
$day=new DateTime('last day of this month');
echo $day->format('M jS');
?>
The date function documentation says that t
represents number of days in current month:
$day = date( 't-m-Y' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With