PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / trunk
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance vtrunk
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / monolog / monolog / src / Monolog / DateTimeImmutable.php

DateTimeImmutable.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance trunk, at vendor/monolog/monolog/src/Monolog/DateTimeImmutable.php

50 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Monolog;
13
14 use DateTimeZone;
15
16 /**
17 * Overrides default json encoding of date time objects
18 *
19 * @author Menno Holtkamp
20 * @author Jordi Boggiano <[email protected]>
21 */
22 class DateTimeImmutable extends \DateTimeImmutable implements \JsonSerializable
23 {
24 /**
25 * @var bool
26 */
27 private $useMicroseconds;
28
29 public function __construct(bool $useMicroseconds, ?DateTimeZone $timezone = null)
30 {
31 $this->useMicroseconds = $useMicroseconds;
32
33 parent::__construct('now', $timezone);
34 }
35
36 public function jsonSerialize(): string
37 {
38 if ($this->useMicroseconds) {
39 return $this->format('Y-m-d\TH:i:s.uP');
40 }
41
42 return $this->format('Y-m-d\TH:i:sP');
43 }
44
45 public function __toString(): string
46 {
47 return $this->jsonSerialize();
48 }
49 }
50