I am testing some code using PHP’s strtotime() function, but I can’t work out how PHP is interpreting the following:
strtotime('first day of this year')
I get Tue Sep 01 2015 (currently it is Sunday 27 September in Australia).
Is this some strange new usage of “year” that I was previously unaware of?
If you don't mention the month (and you don't), strtotime is built to assume you mean the current month. The same goes with year, btw; that's why it's enough to build your expression as simple as...
strtotime('first day of January');
, as this year will be used if skipped in definition anyway.
Note the difference with...
strtotime('first day of first month');
This will give you October, 1 (in September), as it's the first day of the first month since current.
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