Time::to()
Converts current date/time zone to other date/time zone.
Table of Contents
Description
Time::to(?string $zone = zone(), ?string $offset = null): Time;This method converts the current date/time value to the date/time value in another time zone.
Example
$time = new Time;
echo $time->to('UTC')->format('Y-m-d H:i:s'); // Returns `'2026-02-03 00:28:03'`
echo $time->to('Asia/Jakarta')->format('Y-m-d H:i:s'); // Returns `'2026-02-03 07:28:03'`
echo $time->to('Asia/Jakarta', '+1 day')->format('Y-m-d H:i:s'); // Returns `'2026-02-04 07:28:03'`Time::_()
The dynamic method initiator.
Time::__call()
Proxy for missing methods.
Time::__callStatic()
Proxy for missing static methods.
Time::__construct()
The constructor.
Time::__get()
Proxy for missing properties.
Time::__invoke()
Proxy for the current object, called as a function.
Time::__serialize()
Provides data to be serialized.
Time::__toString()
Proxy for the current object, casted as a string.
Time::__unserialize()
Converts the serialized data back to its object.
Time::date()
Returns the day of the month.
Time::day()
Returns the day number of the week, or the day name.
Time::format()
Returns the date/time formatted according to the given format.
Time::from()
Object instantiator.
Time::hour()
Returns the hour number.
Time::i()
Returns the date/time formatted according to the given pattern.
Time::minute()
Returns the minute number.
Time::month()
Returns the month number, or the month name.
Time::name()
Returns the date/time format as a valid file name.
Time::second()
Returns the second number.
Time::to()
Converts current date/time zone to other date/time zone.
Time::year()
Returns the year number.