Thursday, October 2, 2025
HomeLanguagesPHP | IntlCalendar getFirstDayOfWeek() Function

PHP | IntlCalendar getFirstDayOfWeek() Function

The IntlCalendar::getFirstDayOfWeek() function is an inbuilt function in PHP which is used to return the first day of the week for the calendar.

Syntax:

  • Object oriented style
    int IntlCalendar::getFirstDayOfWeek( void )
  • Procedural style
    int intlcal_get_first_day_of_week( IntlCalendar $cal )

Parameters: This function uses single parameter $cal which holds the resource of IntlCalendar.

Return Value: This function returns one of the IntlCalendar field constants like IntlCalendar::DOW_SUNDAY, IntlCalendar::DOW_MONDAY, …, IntlCalendar::DOW_SATURDAY on success or FALSE on failure.

Below program illustrates the IntlCalendar::getFirstDayOfWeek() function in PHP:

Program:




<?php
  
// Set the DateTime zone
ini_set('date.timezone', 'Asia/Calcutta');
ini_set('date.timezone', 'UTC');
  
// Set the DateTime object
$calendar1 = IntlCalendar::fromDateTime('2019-09-22');
  
// Use getFirstDayOfWeek() function to get
// the first day of week
var_dump($calendar1->getFirstDayOfWeek());
  
// Get the week of year
var_dump($calendar1->get(IntlCalendar::FIELD_WEEK_OF_YEAR));
  
// Create an instance of calendar
$calendar2 = IntlCalendar::createInstance(NULL, 'en_US');
  
// Use getFirstDayOfWeek() function to get
// the first day of week
var_dump($calendar2->getFirstDayOfWeek());
  
// Set the date to the calendar
$calendar2->set(2020, 05, 20);
  
// Check the given month is leap or not
var_dump($calendar2->get(IntlCalendar::FIELD_IS_LEAP_MONTH)); 
  
?>


Output:

int(1)
int(39)
int(1)
int(0)

Reference: https://www.php.net/manual/en/intlcalendar.getfirstdayofweek.php

RELATED ARTICLES

Most Popular

Dominic
32331 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11926 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7079 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS