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