Recent Posting
Getting first and last day of the month
So I wanted a compact way of doing this using PHP without using a function or method and show the date in format d/m/yyyy. The first day of the month is straight forward and I could have used something simple like this:
$dtFirstDay = "1/" . date("m") ."/" . date("Y") ;
This could have done it but in the end I settled for a method with similar formulations for both first day and last day and hence:
$dtFirstDay = date("j/n/Y", mktime(0, 0, 0, date("m") , date("d")-date("d")+1, date("Y")));
and for last day:
$dtLastDay = date("j/n/Y", mktime(0, 0, 0, date("m")+1 , date("d")-date("d"), date("Y")));