PHP | IntlCalendar isWeekend() Function
The IntlCalendar::isWeekend() function is an inbuilt function in PHP which is used to check whether a given date/time is in the weekend or not.
Syntax:
- Object oriented style
bool IntlCalendar::isWeekend( float $date = NULL )
- Procedural style
bool intlcal_is_weekend( IntlCalendar $cal, float $date = NULL )
Parameters: This function uses two parameters as mentioned above and described below:
- $cal: This parameter holds the resource of IntlCalendar object.
- $date: This parameter holds the optional timestamp which represents the number of milliseconds since the epoch, excluding leap seconds. If the value of this parameter is NULL then it uses the current time.
Return Value: This function returns the Boolean value which represents the given time occurs in a weekend or not.
Below program illustrates the IntlCalendar::isWeekend() function in PHP:
Program:
<?php
ini_set ( 'date.timezone' , 'Asia/Calcutta' );
$calendar = IntlCalendar::createInstance( 'Asia/Calcutta' );
var_dump( $calendar ->isWeekend());
$calendar ->set(2019, 8, 29);
var_dump( $calendar ->isWeekend());
$calendar ->isWeekend( strtotime ( '2019-09-22 12:30:00' ));
var_dump( $calendar ->isWeekend());
?>
|
Output:
bool(false)
bool(true)
bool(true)
Reference: https://www.php.net/manual/en/intlcalendar.isweekend.php
Last Updated :
25 Sep, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...