I'm trying to get the same seek number with PHP (Carbon - laravel) and MySql using the same date. At the end of the year, PHP returns week 53 and Mysql, using the same date, returns 52 but both starts with week number 1, how can this be possible?
Here is an example:
Same date, different output:
PHP:
$phpDate = Carbon::create('2020','12','31');
dd($phpDate->format('W'));
//output - 53
MySql
select DATE_FORMAT("2020-12-31", '%V') from aRandomTable
//output 52
And then i questioned, maybe, MySQL is starting on Zero, but then i made another try:
PHP:
$phpDate = Carbon::create('2021','01','05');
dd($phpDate->format('W'));
//output - 01
MySQL
select DATE_FORMAT("2021-01-05", '%V') from aRandomTable
//output - 01
And both start with week 1.
Why this happens? How can i fix this?