/** * Gets the transition instant as an epoch second. * * @return int the transition epoch second */ public function toEpochSecond() { return $this->transition->toEpochSecond($this->offsetBefore); }
/** * Converts this date-time to the number of seconds from the epoch of 1970-01-01T00:00:00Z. * <p> * This allows this date-time to be converted to a value of the * {@link ChronoField#INSTANT_SECONDS epoch-seconds} field. This is primarily * intended for low-level conversions rather than general application usage. * * @return int the number of seconds from the epoch of 1970-01-01T00:00:00Z */ public function toEpochSecond() { return $this->dateTime->toEpochSecond($this->offset); }
/** * Returns a copy of this date-time with a different time-zone, * retaining the instant. * <p> * This method changes the time-zone and retains the instant. * This normally results in a change to the local date-time. * <p> * This method is based on retaining the same instant, thus gaps and overlaps * in the local time-line have no effect on the result. * <p> * To change the offset while keeping the local time, * use {@link #withZoneSameLocal(ZoneId)}. * * @param ZoneId $zone the time-zone to change to, not null * @return ZonedDateTime a {@code ZonedDateTime} based on this date-time with the requested zone, not null * @throws DateTimeException if the result exceeds the supported date range */ public function withZoneSameInstant(ZoneId $zone) { return $this->zone->equals($zone) ? $this : self::create($this->dateTime->toEpochSecond($this->offset), $this->dateTime->getNano(), $zone); }