timeElapsed() public static method

Example: ~~~ echo Enum::timeElapsed('21-Jan-2016'); ~~~
public static timeElapsed ( string $fromTime = null, boolean $human = true, string $toTime = null, string $append = null ) : string
$fromTime string start date time
$human boolean if true returns an approximate human friendly output. If set to `false`, will attempt an exact conversion of time intervals.
$toTime string end date time (defaults to current system time)
$append string the string to append for the converted elapsed time. Defaults to ' ago'. Example Output(s): 10 hours ago
return string
Esempio n. 1
0
 public function data() {
     $userField = $this->userField;
     $output = '';
     $models = Chat::records();
     if ($models)
         foreach ($models as $model) {
             if (isset($model->user->$userField)) {
                 $avatar = $model->user->$userField;
             } else{
                 $avatar = Yii::$app->assetManager->getPublishedUrl("@vendor/sintret/yii2-chat-adminlte/assets/img/avatar.png");
             }
                 
             $output .= '<div class="item">
             <img class="online" alt="user image" src="' . $avatar . '">
             <p class="message">
                 <a class="name" href="#">
                     <small class="text-muted pull-right" style="color:green"><i class="fa fa-clock-o"></i> ' . \kartik\helpers\Enum::timeElapsed($model->updateDate) . '</small>
                     ' . $model->user->user_name . '
                 </a>
                ' . $model->message . '
             </p>
         </div>';
         }
     return $output;
 }
 public function getTimeago()
 {
     if ($this->createDate) {
         return Enum::timeElapsed($this->createDate);
     }
 }
Esempio n. 3
0
 public function data($status = 0)
 {
     $output = '';
     $models = $this->records($status);
     $num = 0;
     if ($models) {
         foreach ($models as $model) {
             $checked = $model->status == 1 ? "checked" : "";
             $output .= '<li>
             <!-- drag handle -->
             <span class="handle">
                 <i class="fa fa-ellipsis-v"></i>
                 <i class="fa fa-ellipsis-v"></i>
             </span>
             <!-- checkbox -->
             <input type="checkbox" ' . $checked . ' class="todolistCheck" value="' . $model->id . '" name="list"/>
             <!-- todo text -->
             <span class="text">' . $model->title . '</span>
             <!-- Emphasis label -->
             <small class="label label-' . self::$labels[$num] . '"><i class="fa fa-clock-o"></i>' . \kartik\helpers\Enum::timeElapsed($model->createDate) . '</small>
             <!-- General tools such as edit or delete-->
             <div class="tools">
                 <i class="fa fa-edit"></i>
                 <i class="fa fa-trash-o"></i>
             </div>
         </li>';
             $num++;
         }
     }
     return $output;
 }