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

IntlCalendar::fromDateTime

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

IntlCalendar::fromDateTime — Create an IntlCalendar from a DateTime object or string

Description

Object oriented style

代码语言:javascript
复制
public static IntlCalendar IntlCalendar::fromDateTime ( mixed $dateTime )

Procedural style

代码语言:javascript
复制
IntlCalendar intlcal_from_date_time ( mixed $dateTime )

Creates an IntlCalendar object either from a DateTime object or from a string from which a DateTime object can be built.

The new calendar will represent not only the same instant as the given DateTime (subject to precision loss for dates very far into the past or future), but also the same timezone (subject to the caveat that different timezone databases will be used, and therefore the results may differ).

Parameters

dateTime

A DateTime object or a string that can be passed to DateTime::__construct().

Return Values

The created IntlCalendar object or NULL in case of failure. If a string is passed, any exception that occurs inside the DateTime constructor is propagated.

Examples

Example #1 IntlCalendar::fromDateTime()

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

//same?as?IntlCalendar::fromDateTime(new?DateTime(...))
$cal1?=?IntlCalendar::fromDateTime('2013-02-28?00:01:02?Europe/Berlin');

//Note?the?timezone?is?Europe/Berlin,?not?the?default?Europe/Lisbon
echo?IntlDateFormatter::formatObject($cal1,?'yyyy?MMMM?d?HH:mm:ss?VVVV',?'de_DE'),?"\n";

The above example will output:

代码语言:javascript
复制
2013 Februar 28 00:01:02 Deutschland Zeit

← IntlCalendar::fieldDifference

IntlCalendar::get →

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com