PHP | IntlCalendar setFirstDayOfWeek() Function
Last Updated :
25 Sep, 2019
The IntlCalendar::setFirstDayOfWeek() function is an inbuilt function in PHP which is used to set the day on which the week is to be started. This function affects the behaviors of fields that depend on the week such as IntlCalendar::FIELD_WEEK_OF_YEAR and IntlCalendar::FIELD_YEAR_WOY.
Syntax:
- Object oriented style
bool IntlCalendar::setFirstDayOfWeek( int $dayOfWeek )
- Procedural style
bool intlcal_set_first_day_of_week( IntlCalendar $cal, int $dayOfWeek )
Parameters: This function uses two parameters as mentioned above and described below:
- $cal: This parameter holds the resource of IntlCalendar object.
- $dayOfWeek: This parameter holds one of the field constants such as IntlCalendar::DOW_SUNDAY, IntlCalendar::DOW_MONDAY, …, IntlCalendar::DOW_SATURDAY.
Return Value: This function returns True on success and False in case of invalid parameters.
Below program illustrates the IntlCalendar::setFirstDayOfWeek() function in PHP:
Program:
<?php
ini_set ( 'date.timezone' , 'Asia/Calcutta' );
ini_set ( 'intl.default_locale' , 'es_ES' );
$calendar = IntlCalendar::createInstance( 'Asia/Calcutta' );
$calendar ->set(2019, 8, 25);
var_dump( $calendar ->getFirstDayOfWeek());
$calendar ->setFirstDayOfWeek(IntlCalendar::DOW_SUNDAY);
var_dump( $calendar ->getFirstDayOfWeek());
?>
|
Reference: https://www.php.net/manual/en/intlcalendar.setfirstdayofweek.php
Share your thoughts in the comments
Please Login to comment...