當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Date::ago方法代碼示例

本文整理匯總了PHP中Jenssegers\Date\Date::ago方法的典型用法代碼示例。如果您正苦於以下問題:PHP Date::ago方法的具體用法?PHP Date::ago怎麽用?PHP Date::ago使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Jenssegers\Date\Date的用法示例。


在下文中一共展示了Date::ago方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: build

 public function build()
 {
     $translator = $this->processor->getTranslator();
     $html = "";
     Date::setLocale($this->locale);
     if ($this->printStyles) {
         $html .= $this->getStylesHtml();
     }
     $hidden = $this->isModal ? ' style="display:none;"' : '';
     if ($this->printFrame) {
         $html .= '<div id="changemodal-wrapper"' . $hidden . '><div id="changemodal"' . $hidden . '><div id="changemodal-frame"><h1>' . $this->title . '</h1>';
         if ($this->isModal) {
             $html .= '<i id="close-button" class="fa fa-times"></i>';
         }
     } else {
         $html .= '<div id="changemodal">';
     }
     $html .= '<div class="changelog">';
     try {
         foreach ($this->processor->getVersions() as $version) {
             $html .= '<h2 id="' . $version->getVersion() . '"';
             if ($version->isYanked()) {
                 $html .= ' class="yanked" title="' . $translator->translateTo('This release has been yanked.') . '"';
             }
             $html .= '>' . $version->getVersion() . '</h2>';
             if ($version->isReleased() && $version->getReleaseDate() !== null) {
                 $date = new Date($version->getReleaseDate()->getTimestamp());
                 $html .= '<h3 title="' . '">' . $date->ago();
                 if ($this->printDownloadLinks && !$version->isYanked()) {
                     $html .= ' <a href="' . $version->getUrl() . '" target="_blank"><i class="fa fa-download"></i></a>';
                 }
                 $html .= '</h3>';
             }
             $html .= '<div class="version-wrapper">';
             foreach ($version->getChanges() as $label => $changes) {
                 $html .= '<ul class="' . $label . '">';
                 foreach ($changes as $change) {
                     $html .= '<li data-label="' . ucfirst($translator->translateTo($label)) . '">' . $change . '</li>';
                 }
                 $html .= '</ul>';
             }
             $html .= '</div>';
         }
     } catch (\Exception $e) {
         $html .= '<div class="alert alert-danger" style="text-align: center" role="alert">' . '<i class="fa fa-lg fa-exclamation-triangle"></i><br>' . '<b>Could not get Changelog!</b><br>' . 'Error: <em>' . $e->getMessage() . '</em>' . '</div>';
     }
     $html .= '</div></div>';
     if ($this->printFrame) {
         $html .= '</div>';
     }
     if ($this->printScripts) {
         $html .= $this->getScriptsHtml();
     }
     return $html;
 }
開發者ID:Syonix,項目名稱:changelog-viewer,代碼行數:55,代碼來源:HtmlFormatter.php

示例2: getDateAgoStr

 public static function getDateAgoStr($time_str)
 {
     $date = new Date($time_str);
     return $date->ago();
 }
開發者ID:serovvitaly,項目名稱:new.jp.appros.ru,代碼行數:5,代碼來源:DateHelper.php

示例3: formatHumanTime

 public static function formatHumanTime($timestamp)
 {
     Date::setLocale('vi');
     $date = new Date((int) $timestamp);
     return $date->ago();
 }
開發者ID:nguyenducduy,項目名稱:haraapp,代碼行數:6,代碼來源:Utils.php


注:本文中的Jenssegers\Date\Date::ago方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。