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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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)); 
  
?>

chevron_right


Output:

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

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

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.