i want to check if today is the last day of the month, but i don\'t really know how. i want to write it in php.
can you help?
thanks, Sebastian
$date = new DateTime('last day of this month');
$numDaysOfCurrentMonth = $date->format('d');
Use date function:
if (date('t') == date('j'))
{
...
}
this is to find the days in any month:
$days = intval(date('t', strtotime($desiredDate)));
date('t');
or you may use
cal_days_in_month.
see here: http://php.net/manual/en/function.cal-days-in-month.php
And here it is, wrapped up as a function:
function is_last_day_of_month($timestamp = NULL) {
if(is_null($timestamp))
$timestamp = time();
return date('t', $timestamp) == date('j', $timestamp);
}