Time::to()

Converts current date/time zone to other date/time zone.

Table of Contents
  1. Description
  2. Example

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::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::i()

Returns the date/time formatted according to the given pattern.

Time::name()

Returns the date/time format as a valid file name.

Time::to()

Converts current date/time zone to other date/time zone.