Ik ben op zoek naar een exacte functie van WEEK() in php waarbij de weken precies hetzelfde zijn.
Het probleem waar ik op het moment mee zit is dat als ik
WEEK(NOW()) doe, hij 15 zegt en wanneer ik
date('W') in php doe, hij 16 weergeeft.
Nu ben ik er van op de hoogte dat je bij week enkele mode's in kan geven:
<?php
First day
Mode of week Range Week 1 is the first week …
0 Sunday 0-53 with a Sunday in this year
1 Monday 0-53 with more than 3 days this year
2 Sunday 1-53 with a Sunday in this year
3 Monday 1-53 with more than 3 days this year
4 Sunday 0-53 with more than 3 days this year
5 Monday 0-53 with a Monday in this year
6 Sunday 1-53 with more than 3 days this year
7 Monday 1-53 with a Monday in this year
?>
maar ik vraag mij dus af welke mode PHP aanhoud, kennelijk is dit dus niet de standaard mode.
This function returns the week number for date. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used. See Section 5.1.3, “System Variables”.
The following table describes how the mode argument works.
First day
Mode of week Range Week 1 is the first week …
0 Sunday 0-53 with a Sunday in this year
1 Monday 0-53 with more than 3 days this year
2 Sunday 1-53 with a Sunday in this year
3 Monday 1-53 with more than 3 days this year
4 Sunday 0-53 with more than 3 days this year
5 Monday 0-53 with a Monday in this year
6 Sunday 1-53 with more than 3 days this year
7 Monday 1-53 with a Monday in this year
One might argue that MySQL should return 52 for the WEEK() function, because the given date actually occurs in the 52nd week of 1999. We decided to return 0 instead because we want the function to return “the week number in the given year.” This makes use of the WEEK() function reliable when combined with other functions that extract a date part from a date.
If you would prefer the result to be evaluated with respect to the year that contains the first day of the week for the given date, use 0, 2, 5, or 7 as the optional mode argument.
Vreemd genoeg krijg ik als ik [code language="php"] $sql="SELECT week(current_DATE), 1"; [/code] invoer in een PHP document geen resultaat. Weet iemand hoe ik dit oplos?