SMF Development > Bug Reports
Week 52 and 1 overlap when monday first day of the week
Thantos:
Like all date and calendar issues it is regional. But ISO 8601 does define how the weeks are counted. And the first week is the week that contains the first Thursday.
--- Code: ---<?php
$dates = array(
'Jan 1, 2007', // Monday
'Jan 1, 2008', // Tues
'Jan 1, 2014', // Wed
'Jan 1, 2009', // Thur
'Jan 1, 2010', // Fri
'Jan 1, 2011', // Sat
'Jan 1, 2012', // Sun
);
echo '
<ul>';
foreach ($dates AS $date)
{
$ts = strtotime($date);
echo '<li>', $date, ': ', date('N W', $ts), '</li>'; // N is the day of the week, W is the week number
}
echo '
</ul>';
--- End code ---
Navigation
[0] Message Index
[*] Previous page
Go to full version