32 lines
777 B
PHP
32 lines
777 B
PHP
<?php
|
|
|
|
use Carbon\Carbon;
|
|
|
|
if (! function_exists('formatDate')) {
|
|
function formatDate(?string $date = null, ?string $format = 'l, d M Y'): string
|
|
{
|
|
return ! $date ? '-' : Carbon::parse($date)->translatedFormat($format);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('formatDateTime')) {
|
|
function formatDateTime(string $dateTime): string
|
|
{
|
|
return Carbon::parse($dateTime)->translatedFormat('l, d M Y H:i:s');
|
|
}
|
|
}
|
|
|
|
if (! function_exists('formatDateDash')) {
|
|
function formatDateDash(string $date): string
|
|
{
|
|
return Carbon::parse($date)->translatedFormat('Y-m-d');
|
|
}
|
|
}
|
|
|
|
if (! function_exists('timeAgo')) {
|
|
function timeAgo(?string $date = null): string
|
|
{
|
|
return ! $date ? '-' : Carbon::parse($date)->diffForHumans();
|
|
}
|
|
}
|