Skip to content

DayOfWeek

A day of the week: what a week is told to start on.

A week starts on Monday in ISO 8601 and most of the world, on Sunday in the United States, Canada, Japan and Israel, and on Saturday in much of the Middle East. A machine's locale would pick one answer on a developer's laptop and another on the server, so the library never asks it: the methods that need to know take a DayOfWeek, and you say. The numbers are the ones PHP's date('w') writes — Sunday is 0, Saturday is 6.

Members

Member Value Meaning
Sunday 0 The first day of the week in the United States, Canada, Japan and Israel.
Monday 1 The first day of the week in ISO 8601 and most of the world. This is the default.
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6 The first day of the week in much of the Middle East.

Where it is used

CkDate.StartOfWeek and CkDate.EndOfWeek take a firstDay parameter, Monday by default. The week ends the day before the next firstDay.

Quick look

use SafeCoder\CommonKit\CkDate;
use SafeCoder\CommonKit\Enums\DayOfWeek;

CkDate::StartOfWeek('2026-09-02');    // -> CkDay 2026-08-31T00:00:00Z  (a Wednesday; the Monday before)
CkDate::EndOfWeek('2026-09-02');      // -> CkDay 2026-09-06T00:00:00Z  (the Sunday after)

CkDate::StartOfWeek(
    input: '2026-09-02',
    firstDay: DayOfWeek::Sunday
);                                    // -> CkDay 2026-08-30T00:00:00Z

CkDate::EndOfWeek(
    input: '2026-09-02',
    firstDay: DayOfWeek::Sunday
);                                    // -> CkDay 2026-09-05T00:00:00Z

DayOfWeek::from(0);                   // -> DayOfWeek::Sunday  (the number date('w') writes)