Skip to content

Time offsets

This is a value retrieved from a point in time and is expressed in a number of hours and minutes.

use Innmind\TimeContinuum\Clock;

$offset = Clock::live()->now()->offset();
  • $offset->hours() returns an int between -12 and 14
  • $offset->minutes() returns an int between 0 and 59

Via this object you cannot know in which timezone you're in. If you need to keep track of this you should model this in your program and not rely on this information.

When you have access to a PointInTime you can change its offset like this:

use Innmind\TimeContinuum\{
    Clock,
    Offset,
};

$utc = Clock::live()->now();
$newYork = $utc->changeOffset(Offset::minus(5));

If $utc represents '2024-11-24T14:25:00+00:00' then $newYork represents '2024-11-24T09:25:00-05:00'.