<?php
class Demo
{
public function __construct(DateTimeInterface $dateTime) {
$this->date = $dateTime;
}
public function getDateTime(): DateTimeInterface { return $this->date; }
public function echo() { echo $this->date->format("d/m/Y h:i:s"); }
}
$demo = new Demo(new DateTime());
$demo->echo()."\n";
$demo->getDateTime()->add(new DateInterval('+1D'));
$demo->echo();
Deprecated: Creation of dynamic property Demo::$date is deprecated in /in/ATBao on line 5
30/10/2018 10:29:55
Fatal error: Uncaught DateMalformedIntervalStringException: Unknown or bad format (+1D) in /in/ATBao:13
Stack trace:
#0 /in/ATBao(13): DateInterval->__construct('+1D')
#1 {main}
thrown in /in/ATBao on line 13
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Deprecated: Creation of dynamic property Demo::$date is deprecated in /in/ATBao on line 5
30/10/2018 10:29:55
Fatal error: Uncaught DateMalformedIntervalStringException: Unknown or bad format (+1D) in /in/ATBao:13
Stack trace:
#0 /in/ATBao(13): DateInterval->__construct('+1D')
#1 {main}
thrown in /in/ATBao on line 13
Process exited with code 255.
Output for 8.2.0 - 8.2.18
Deprecated: Creation of dynamic property Demo::$date is deprecated in /in/ATBao on line 5
30/10/2018 10:29:55
Fatal error: Uncaught Exception: Unknown or bad format (+1D) in /in/ATBao:13
Stack trace:
#0 /in/ATBao(13): DateInterval->__construct('+1D')
#1 {main}
thrown in /in/ATBao on line 13
Process exited with code 255.
Output for 8.1.0 - 8.1.28
30/10/2018 10:29:55
Fatal error: Uncaught Exception: Unknown or bad format (+1D) in /in/ATBao:13
Stack trace:
#0 /in/ATBao(13): DateInterval->__construct('+1D')
#1 {main}
thrown in /in/ATBao on line 13
Process exited with code 255.
30/10/2018 10:29:55
Fatal error: Uncaught Exception: DateInterval::__construct(): Unknown or bad format (+1D) in /in/ATBao:13
Stack trace:
#0 /in/ATBao(13): DateInterval->__construct('+1D')
#1 {main}
thrown in /in/ATBao on line 13
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 8.0.13
30/10/2018 09:29:55
Fatal error: Uncaught Exception: DateInterval::__construct(): Unknown or bad format (+1D) in /in/ATBao:13
Stack trace:
#0 /in/ATBao(13): DateInterval->__construct('+1D')
#1 {main}
thrown in /in/ATBao on line 13
Process exited with code 255.
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/ATBao on line 7
Process exited with code 255.