IntlCalendar::isWeekend
(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)
IntlCalendar::isWeekend — Whether a certain date/time is in the weekend
Description
Object oriented style
$date
= NULL
] ) : boolProcedural style
Returns whether either the obejctʼs current time or the provided timestamp occur during a weekend in this objectʼs calendar system.
This function requires ICU 4.4 or later.
Parameters
-
cal
-
The IntlCalendar resource.
-
date
-
An optional timestamp representing the number of milliseconds since the epoch, excluding leap seconds. If
NULL
, this objectʼs current time is used instead.
Return Values
A bool indicating whether the given or this objectʼs time occurs in a weekend.
The value FALSE
may also be returned on failure, for instance after giving
a date out of bounds on non-lenient mode; use exceptions or query
intl_get_error_code() to disambiguate.
Examples
Example #1 IntlCalendar::isWeekend()
<?php
ini_set('date.timezone', 'Europe/Lisbon');
$cal = new IntlGregorianCalendar(NULL, 'en_US');
$cal->set(2013, 6 /* July */, 7); // a Sunday
var_dump($cal->isWeekend()); // true
var_dump($cal->isWeekend(strtotime('2013-07-01 00:00:00'))); // false, Monday
$cal = new IntlGregorianCalendar(NULL, 'ar_SA');
$cal->set(2013, 6 /* July */, 7); // a Sunday
var_dump($cal->isWeekend()); // false, Sunday not in weekend in this calendar
See Also
- IntlCalendar::getDayOfWeekType() - Tell whether a day is a weekday, weekend or a day that has a transition between the two
- IntlCalendar::getWeekendTransition() - Get time of the day at which weekend begins or ends
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-intlcalendar.isweekend.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.