Initial import of animal_management module
This commit is contained in:
25
helpers/DateDisplayHelper.php
Normal file
25
helpers/DateDisplayHelper.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user