本文整理汇总了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;
}
示例2: getDateAgoStr
public static function getDateAgoStr($time_str)
{
$date = new Date($time_str);
return $date->ago();
}
示例3: formatHumanTime
public static function formatHumanTime($timestamp)
{
Date::setLocale('vi');
$date = new Date((int) $timestamp);
return $date->ago();
}