Example #1
0
 /**
  * Outputs this date-time as a {@code String}, such as {@code 2007-12-03T10:15:30+01:00}.
  * <p>
  * The output will be one of the following ISO-8601 formats:
  * <ul>
  * <li>{@code uuuu-MM-dd'T'HH:mmXXXXX}</li>
  * <li>{@code uuuu-MM-dd'T'HH:mm:ssXXXXX}</li>
  * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSSXXXXX}</li>
  * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSXXXXX}</li>
  * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSXXXXX}</li>
  * </ul>
  * The format used will be the shortest that outputs the full value of
  * the time where the omitted parts are implied to be zero.
  *
  * @return string a string representation of this date-time, not null
  */
 public function __toString()
 {
     return $this->dateTime->__toString() . $this->offset->__toString();
 }
Example #2
0
 /**
  * Outputs this date-time as a {@code String}, such as
  * {@code 2007-12-03T10:15:30+01:00[Europe/Paris]}.
  * <p>
  * The format consists of the {@code LocalDateTime} followed by the {@code ZoneOffset}.
  * If the {@code ZoneId} is not the same as the offset, then the ID is output.
  * The output is compatible with ISO-8601 if the offset and ID are the same.
  *
  * @return string a string representation of this date-time, not null
  */
 public function __toString()
 {
     $str = $this->dateTime->__toString() . $this->offset->__toString();
     // equals
     if ($this->offset != $this->zone) {
         $str .= '[' . $this->zone->__toString() . ']';
     }
     return $str;
 }