Nov 152012
 

Google – last day of month php – and you’ll get over 15,000,000 results.  It’s amazing how many people have searched for this & how many roundabout ways there are to accomplish what should be a simple task.

Here is the simplest way (that I know of) to get the last day of the month using PHP.

Get last day of the current month

$lastday = date(‘t’,strtotime(‘today’));

 Get last day of next month

$lastday = date(‘t’,strtotime(‘next month’));

Get last day of any other month
Enter any month/day/year to get the last day of that month

$lastday = date(‘t’,strtotime(‘3/1/2009’));

If you want to display the last day of this month on your website, do the following:

<?php
echo date(‘t’,strtotime(‘today’));
?>

Sumber :  http://www.johnboy.com/blog/find-the-last-day-of-the-month-with-php

Facebook Comments

  One Response to “Find the Last Day of the Month With PHP”

  1. Wahh, nambah wawasan banget nih gan

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)