Change the week start day from Monday to Saturday

To display the number of weekday I use the following:

echo “Today’s date is: ” . date(“Y/m/d”) . “<br>”;
echo “The weekday is: ” . date(“l”) . “<br>”;
echo “The number of the weekday is: ” . date(“N”) . “<br>”;
echo “The week number is:” . date(“W”);

When the day is a Monday the above returns “The number of the weekday is: 1”. This is because the week starts on Monday by default.
What I need is to change the week start day to Saturday.
Then the above “The number of the weekday is: ” will return 3 on Mondays and 1 on Saturdays. In this regard the week number in a given date will be affected accordingly.

I have found this code in https://stackoverflow.com/questions/13128854/php-datetime-class-change-first-day-of-the-week-to-monday intended to change first day of the week from Saturday to Monday

class EuroDateTime extends DateTime {

// Override “modify()”
public function modify($string) {

// Change the modifier string if needed
if ( $this->format(‘N’) == 1 ) { // It’s Sunday and we’re calculating a day using relative weeks
$matches = array();
$pattern = ‘/this week|next week|previous week|last week/i’;
if ( preg_match( $pattern, $string, $matches )) {
$string = str_replace($matches[0], ‘-7 days ‘.$matches[0], $string);
}
}
return parent::modify($string);

}

but I have not succeeded in modifying it so to change the week start day to Saturday.

Can anyone suggest the modification needed or another code snippet which will turn the week start day to Saturday?

Read more here:: Change the week start day from Monday to Saturday

Leave a Reply

Your email address will not be published. Required fields are marked *