(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a2)
IntlCalendar::fromDateTime — Create an IntlCalendar from a DateTime object or string
DescriptionObject-oriented style
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).
Return ValuesThe created IntlCalendar object or null
in case of failure. If a string is passed, any exception that occurs inside the DateTime constructor is propagated.
Example #1 IntlCalendar::fromDateTime()
<?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:
2013 Februar 28 00:01:02 Deutschland Zeit
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4