Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
TimeUsing.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
4 use DateTime;
5 
11 trait TimeUsing {
12 
16  private $time;
17 
26  public function getCurrentTime($modifier = '') {
27  $time = $this->time ? $this->time : new DateTime();
28  $time = clone $time;
29  if ($modifier) {
30  $time->modify($modifier);
31  }
32  return $time;
33  }
34 
41  public function setCurrentTime(DateTime $time = null) {
42  if (!$time) {
43  $time = new DateTime();
44  }
45  $this->time = clone $time;
46  }
47 }
getCurrentTime($modifier= '')
Get the (cloned) time.
Definition: TimeUsing.php:26
trait TimeUsing
Adds methods for setting the current time (for testing)
Definition: TimeUsing.php:11
setCurrentTime(DateTime $time=null)
Set the current time.
Definition: TimeUsing.php:41