How to get timestamp of current month, first day of month, zero hour

MultiDev picture MultiDev · Jun 28, 2012 · Viewed 22.7k times · Source

I am trying to get the timestamp of the first day of the month at 00:00:00.

For example, the timestamp of Jan 01 2012 00:00:00

I'm doing this:

$test_month = time(); // Seconds
$test_month = date('M', $test_month); // This month
$test_month = strtotime($test_month); // Timestamp of this month
echo $test_month;

This is returning zero hour of the current day of the month, not the start of the month.

Any suggestions?

Answer

nickb picture nickb · Jun 28, 2012

Try this:

echo date( 'F jS Y h:i:s A', strtotime( 'first day of ' . date( 'F Y')));

This will output:

June 1st 2012 12:00:00 AM