Skip to content

Commit

Permalink
datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Mar 15, 2015
1 parent 27c8658 commit fbf0d97
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Presenters/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ public function __get($property)
return $this->entity->{$property};
}

/**
* Return resource's datetime or curent date and time if empty
*
* @param string $column
* @return Carbon
*/
public function datetimeOrNow($column = 'date')
{
$date = $this->entity->$column ? : Carbon::now() ;
return $date->format('Y-m-d G:i:s');
}

/**
* Return resource's date or curent date if empty
*
Expand All @@ -58,7 +70,7 @@ public function dateOrNow($column = 'date')
public function timeOrNow($column = 'date')
{
$date = $this->entity->$column ? : Carbon::now() ;
return $date->format('H:i');
return $date->format('G:i');
}

/**
Expand Down

0 comments on commit fbf0d97

Please # to comment.