Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get first day of current month in php? [duplicate]

Tags:

php

What I want to do is get 1st date of current month

Here is how to get last day of the current month

date('d-m-Y', strtotime('last day of this month')) 

I've tried to use this, but it didn't work for me

date('d-m-Y', strtotime('first day of this month'))     

Any idea how to solve my problem ?

like image 385
Oscar Avatar asked May 20 '13 03:05

Oscar


People also ask

How can I get first day of current month in php?

php $dt = "2008-02-23"; echo 'First day : '. date("Y-m-01", strtotime($dt)).

How can I get first date and date of last month in php?

php echo 'First Date = ' . date('Y-m-01') . '<br />'; echo 'Last Date = ' . date('Y-m-t') .

How can I get first week of current month in php?

Use strtotime() function to get the first day of week using PHP. This function returns the default time variable timestamp and then use date() function to convert timestamp date into understandable date. strtotime() Function: The strtotime() function returns the result in timestamp by parsing the time string.


1 Answers

date('01-m-Y') should do it ;)

like image 121
Niet the Dark Absol Avatar answered Sep 25 '22 11:09

Niet the Dark Absol