Version difference for strtotime('first day of last month')?
date, php
Solution
You should use the mktime() function:
<?php
echo date('Y-m-d', mktime(0,0,0,date('n')-1,1,date('Y'))); //2012-03-01
?>
See In Action
Problem
In a script that contains ``` date('Y-m-d', strtotime('first day of last month')) ``` in version 5.3.10 (localhost) I get, for example, '2012-03-01'. in version 5.2.17 (remote host) I get '1969-12-31'. Is there an expression that will return expected (e.g., '2012-03-01') results for both versions?