21 lines
549 B
PHP
21 lines
549 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use Carbon\CarbonInterface;
|
|
|
|
class LocaleFormatting
|
|
{
|
|
public static function number(float $value, int $decimals = 2): string
|
|
{
|
|
return app()->getLocale() === 'en'
|
|
? number_format($value, $decimals, '.', ',')
|
|
: number_format($value, $decimals, ',', ' ');
|
|
}
|
|
|
|
public static function date(?CarbonInterface $value, bool $seconds = false): ?string
|
|
{
|
|
return $value?->format((app()->getLocale() === 'en' ? 'M j, Y H:i' : 'd.m.Y H:i').($seconds ? ':s' : ''));
|
|
}
|
|
}
|