X

Congrats, You are Subscribed to Receive Updates.

PHP function to get first and last date of a month


PHP function to get first and last date of a month. Some times we may need to get the first and last days of a month. For example, if we need to get a monthly transaction . we have the month name or its count. but we need to know the first and last date to do.  So here i am giving you the small piece of code to get the first and last date of a month.

function kvcodes_date_month($month) {

	$start_date = date('Y-'.$month.'-01');
	$end_date = date('Y-'.$month.'-t');	
	
	$result arr = array($start_date, $end_date);
	
	return $result_arr; 
}

and you can just access this function by passing the month count , say for example, if you need to give march month, just pass ” 3″  as the parameter. Just like the following one

$date_arr = kvcodes_date_month(3);

print_r($date_arr);

here it will print the two dates. you can process any month here. Drop your  comments, if you have any doubt and queries.

 

 

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, OpenCart Theme Development, PHP, HTML, CSS, jQuery, Bootstrap development and content SEO.

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar

Subscribe E-mail Updates

Congrats, You are Subscribed to Receive Updates.

Advertisement

Category Posts