Monday, April 16, 2012

How to find first date and last date of month using php

Hi guys, i am going to share and very simple but very important function with you. In this post i am gonna show you how to find first date and last date of current month using php. Here are the two functions,

 <?php  
 function firstOfMonth()  
 {  
      return date("m/d/Y", strtotime(date('m').'/01/'.date('Y').' 00:00:00'));  
 }  
 function lastOfMonth()  
 {  
      return date("m/d/Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));  
 }  
 ?>  

2 comments:

  1. i want that how can we get last date of month without using "t" or anything,,,,,plzzzzzz tell me

    ReplyDelete
  2. how can we get last date of month without using "t" or anything..plzzz tell me

    ReplyDelete

Please feel free to post your comments. If anyone has a good article or good thing to share, just send me that with your name to asadmehmoodstar@gmail.com. and if anyone want so receive updates regarding my blog, he can subscribe to my weekly newsletter on "Subscribe to our mailing list" section.

Thanks