How to get week number in a year in php and mysql?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 views
Hello.

She did not long ago schedule one for weeks

I had raschityval in the selected period the first week and end

I did this so in PHP
$date_start = strtotime("2018-05-03"); // here can the transformation be different $week_start=date("W", $date_start);

That is, we get 18 a week for date 2018-05-03

Do inquiry in base of this type
SELECT `date_invoice` ,WEEK(date_invoice) as week_num FROM `invoce` WHERE `date_invoice` BETWEEN '2018-05-01' AND '2018-05-31'


And get 13 records with dates 2018-05-03 and 2018-05-04

I decided Preminet database for standard function WEEK as you can see from the query
But the problem is that php gives me the date 2018-05-03 - 18 week
but MySQL gives the date 2018-05-03 - 17 week

But in fact PHP is correctly believes

Here is an example of output from the database, for those who do not believe
5aed50c7922d6165595016.jpeg
by | 7 views

1 Answer

0 like 0 dislike
try of the WEEK() to pass in a second parameter of 0 or 1
by
110,608 questions
257,186 answers
0 comments
35,458 users