本文整理汇总了PHP中Mautic\CoreBundle\Helper\DateTimeHelper::getTextDate方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeHelper::getTextDate方法的具体用法?PHP DateTimeHelper::getTextDate怎么用?PHP DateTimeHelper::getTextDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Helper\DateTimeHelper
的用法示例。
在下文中一共展示了DateTimeHelper::getTextDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toText
/**
* Returns date/time like Today, 10:00 AM
*
* @param $datetime
* @param string $timezone
* @param string $fromFormat
*/
public function toText($datetime, $timezone = 'local', $fromFormat = 'Y-m-d H:i:s')
{
if (empty($datetime)) {
return '';
}
$this->helper->setDateTime($datetime, $fromFormat, $timezone);
$textDate = $this->helper->getTextDate();
$dt = $this->helper->getLocalDateTime();
if ($textDate) {
return $this->translator->trans('mautic.core.date.' . $textDate, array('%time%' => $dt->format("g:i a")));
} else {
$interval = $this->helper->getDiff('now', null, true);
return $this->translator->trans('mautic.core.date.ago', array('%days%' => $interval->days));
}
}
示例2: toText
/**
* Returns date/time like Today, 10:00 AM
*
* @param $datetime
* @param string $timezone
* @param string $fromFormat
* @param bool $forceDateForNonText If true, return as full date/time rather than "29 days ago"
*
* @return string
*/
public function toText($datetime, $timezone = 'local', $fromFormat = 'Y-m-d H:i:s', $forceDateForNonText = false)
{
if (empty($datetime)) {
return '';
}
$this->helper->setDateTime($datetime, $fromFormat, $timezone);
$textDate = $this->helper->getTextDate();
$dt = $this->helper->getLocalDateTime();
if ($textDate) {
return $this->translator->trans('mautic.core.date.' . $textDate, array('%time%' => $dt->format("g:i a")));
} else {
$interval = $this->helper->getDiff('now', null, true);
if ($interval->invert && !$forceDateForNonText) {
// In the past
return $this->translator->trans('mautic.core.date.ago', array('%days%' => $interval->days));
} else {
// In the future
return $this->toFullConcat($datetime, $timezone, $fromFormat);
}
}
}