26 lines
523 B
PHP
26 lines
523 B
PHP
<?php
|
|
|
|
namespace humhub\modules\animal_management\helpers;
|
|
|
|
use Yii;
|
|
|
|
class DateDisplayHelper
|
|
{
|
|
public const DATETIME_FORMAT = 'php:m/d/Y h:i A';
|
|
|
|
public static function format(?string $value): string
|
|
{
|
|
$value = trim((string)$value);
|
|
if ($value === '') {
|
|
return '';
|
|
}
|
|
|
|
$timestamp = strtotime($value);
|
|
if ($timestamp === false) {
|
|
return $value;
|
|
}
|
|
|
|
return Yii::$app->formatter->asDatetime($timestamp, self::DATETIME_FORMAT);
|
|
}
|
|
}
|