rhgiant — 2011-12-15T05:55:03-05:00 — #1
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.
martbean — 2011-12-15T06:12:51-05:00 — #2
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'?
rhgiant — 2011-12-15T06:30:05-05:00 — #3
I need to make sure that 'Y' doesn't do what you just described for 'o'.
salathe — 2011-12-15T07:00:07-05:00 — #4
Rest assured, it doesn't.
raju_gautam — 2011-12-15T07:41:24-05:00 — #5
Always see documentation if you get confused:
What is the difference in Y and o or which one is suitable for you!
felgall — 2011-12-15T13:36:08-05:00 — #6
'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.