File: Clock.php Lines 19 to 48 |
|
19 | public function getTime() { |
|
20 | return new \DateTime(); |
|
21 | } |
|
22 | |
|
23 | /** |
|
24 | * 現在時刻を返す |
|
25 | * @return int |
|
26 | */ |
|
27 | public function getTimeAsInt() { |
| | $d = $this->getTime(); |
|
29 | return $d->getTimestamp(); |
|
30 | } |
|
31 | |
|
32 | /** |
|
33 | * 現在時刻を返す |
|
34 | * @return \DateTimeImmutable |
|
35 | * @throws \Exception |
|
36 | */ |
|
37 | public function getTimeAsDTI() { |
| | $d = $this->getTime(); |
|
39 | return new \DateTimeImmutable($d->format('c')); |
|
40 | } |
|
41 | |
|
42 | /** |
|
43 | * scriptの開始時刻を返す |
|
44 | * @return \DateTime |
|
45 | */ |
|
46 | public function getRequestTime() { |
|
47 | $intUnixTime = $this->getRequestTimeAsInt(); |
|
48 | $result = new \DateTime('@'.$intUnixTime); |
|