Elgg  Version 4.x
TimeUsing.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Traits;
4 
10 trait TimeUsing {
11 
15  private $time;
16 
25  public function getCurrentTime($modifier = '') {
26  $time = $this->time ? $this->time : new \DateTime();
27  $time = clone $time;
28  if ($modifier) {
29  $time->modify($modifier);
30  }
31  return $time;
32  }
33 
41  public function setCurrentTime(\DateTime $time = null) {
42  if (!$time) {
43  $time = new \DateTime();
44  }
45  $this->time = clone $time;
46  }
47 }
setCurrentTime(\DateTime $time=null)
Set the current time.
Definition: TimeUsing.php:41
if(!$annotation instanceof ElggAnnotation) $time
Definition: time.php:20
getCurrentTime($modifier= '')
Get the (cloned) time.
Definition: TimeUsing.php:25