How to Get the First Day Of Specific Month In Codeigniter ?

Codeigniter

Nicesnippets

1094

11-01-2021


Hi Guys,

In this example,I will learn you how to get the first day of specific month in codeigniter.you can easy and simply get the first day of specific month in codeigniter.

Sometimes we need How to get the first day of a month from a specific date in codeigniter for various purposes. We can do it in many ways.

Example:


public function index()

{

$query_date = '2021-01-10';

// First day of the month.

echo date('Y-m-01', strtotime($query_date));

}

Output:

2021-01-01

It will help you...