Skip to content

cDateISO::FirstWeekOfMonth()

Rainer Stötter edited this page May 9, 2017 · 1 revision

Method FirstWeekOfMonth( )

 public   \libdatephp\cDateISO libdatephp\cDateISO::FirstWeekOfMonth(integer $month, integer $year)

FirstWeekOfMonth( ) returns the date to the first monday of a month.

If $month and $year are null, then the actual month will be taken

The first week does not start on the 1-st of the month but on the first monday.

without $month and $year: The month the date belongs to according to ISO will be taken as month. ie: If the third January is the date and the month begins according to ISO with the firth January, Then if $strict is false, then the January will be taken as month and the first monday of January will be returned. But if $strict is true, then the first monday of December will be returned.

$dt = new \libdatephp\cDate( 4, 1, 2017 );
for ( $i = 0; $i < 5; $i++ ) {
  $dt = new \libdatephp\cDate( 5, 18, 2017 );
  $dt->GoWOM( $i + 1 );
  echo "\n The week " . ( $i + 1 ) . " starts with " . $dt->AsSQL( ) . '. The month has ' . $dt->WeeksOfMonth( ) . ' weeks';
}

Arguments

  • $month integer - <p>the month to use. Defaults to null. If $month and $year are null, then the actual month and year will be taken</p>
  • $year integer - <p>the year to use. Defaults to null. If $month and $year are null, then the actual month and year will be taken</p>

Returns

\libdatephp\cDateISO the date of the first week of the month

See also

Clone this wiki locally