Hello,
I want to make sure that when January 1st comes, and only January 1st, the function will return the accurate year.
I know that ‘o’ is ISO related, and I’m not sure if that’s the one I should use or not.
Hello,
I want to make sure that when January 1st comes, and only January 1st, the function will return the accurate year.
I know that ‘o’ is ISO related, and I’m not sure if that’s the one I should use or not.
Given that January 1st next year is a Sunday, it’ll still be part of the previous week so ‘o’ will return 2011. Try it:
echo date('o', strtotime('1st January 2012')). '<br>';
echo date('Y', strtotime('1st January 2012'));
I’m not really sure why you’d want to use anything other than ‘Y’?
I need to make sure that ‘Y’ doesn’t do what you just described for ‘o’.
Rest assured, it doesn’t.
Always see documentation if you get confused:
http://www.php.net/manual/en/function.date.php
What is the difference in Y and o or which one is suitable for you!
‘o’ is intended to be used with ‘W’ as that particular version of the year is specifically related to which week of the year that it is. Between the 1st and 3rd January the year in ‘o’ can be one less than in ‘Y’ and between 29th and 31st December it can be one more as the ‘o’ year is always that of the closest Thursday so that week one according to ‘W’ always has at least 4 days.