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?
php $dt = "2008-02-23"; echo 'First day : '. date("Y-m-01", strtotime($dt)).
I would use the strtotime() function, to add +1 month to your timestamp : $future = strtotime('+1 month', $current_time);
php echo 'First Date = ' . date('Y-m-01') . '<br />'; echo 'Last Date = ' . date('Y-m-t') .
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
Try this
$time = strtotime(date('Y-m-01 00:00:00')); // == 1338534000
Which translates to:
$date = date('Y-m-d H:i:s', $time); // == 2012-06-01 00:00:00
Read the PHP manual on the date() and time() functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With