CakeFest 2024: The Official CakePHP Conference

IntlCalendar::isWeekend

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a1)

IntlCalendar::isWeekendある日付/時刻が週末にあるかを調べる

説明

オブジェクト指向型

public IntlCalendar::isWeekend(?float $timestamp = null): bool

手続き型

intlcal_is_weekend(IntlCalendar $calendar, ?float $timestamp = null): bool

オブジェクトの現在時刻、または 指定されたタイムスタンプが、 オブジェクトのカレンダーシステムに照らして、 週末に発生するかを判定して返します。

この関数を使うには、ICU 4.4 以降が必要です。

パラメータ

calendar

IntlCalendar クラスのインスタンス。

timestamp

エポックからの経過時刻をミリ秒単位、 かつうるう秒を除いた値を、 オプションのタイムスタンプとして指定します。 null の場合、 オブジェクトの現在時刻を代わりに使います。

戻り値

指定した、またはこのオブジェクトの時刻が週末に入っているかを bool で返します。

失敗時に false を返します。エラーを検知するには、intl_get_error_code() を使うか、 Intl拡張モジュールが 例外 をスローするように設定して下さい。

例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

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top