首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

IntlCalendar::equals

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

IntlCalendar::equals — Compare time of two IntlCalendar objects for equality

Description

Object oriented style

代码语言:javascript
复制
public bool IntlCalendar::equals ( IntlCalendar $other )

Procedural style

代码语言:javascript
复制
bool intlcal_equals ( IntlCalendar $cal , IntlCalendar $other )

Returns true if this calendar and the given calendar have the same time. The settings, calendar types and field states do not have to be the same.

Parameters

cal

The IntlCalendar resource.

other

The calendar to compare with the primary object.

Return Values

Returns TRUE if the current time of both this and the passed in IntlCalendar object are the same, or FALSE otherwise. The value FALSE can also be returned on failure. This can only happen if bad arguments are passed in. In any case, the two cases can be distinguished by calling intl_get_error_code().

Examples

Example #1 IntlCalendar::equals()

代码语言:javascript
复制
<?php
ini_set('date.timezone',?'UTC');

$cal1?=?IntlCalendar::createInstance(NULL,?'es_ES');
$cal2?=?clone?$cal1;

var_dump($cal1->equals($cal2));?//TRUE

//The?locale?is?not?included?in?the?comparison
$cal2?=?IntlCalendar::createInstance(NULL,?'pt_PT');
$cal2->setTime($cal1->getTime());
var_dump($cal1->equals($cal2));?//TRUE

//And?set?fields?state?is?not?included?as?well
$cal2->clear(IntlCalendar::FIELD_YEAR);
var_dump($cal1->isSet(IntlCalendar::FIELD_YEAR)?==
????????$cal2->isSet(IntlCalendar::FIELD_YEAR));?//FALSE
var_dump($cal1->equals($cal2));?//TRUE

//Neither?is?the?calendar?type
$cal2?=?IntlCalendar::createInstance(NULL,?'es_ES@calendar=islamic');
$cal2->setTime($cal1->getTime());
var_dump($cal1->equals($cal2));?//TRUE

//Only?the?time?is
$cal2?=?clone?$cal1;
$cal2->setTime($cal1->getTime()?+?1.);
var_dump($cal1->equals($cal2));?//FALSE

← IntlCalendar::createInstance

IntlCalendar::fieldDifference →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com