Files
oficial/app/src/Service/Format.php

25 lines
592 B
PHP
Raw Normal View History

<?php
namespace Incoviba\Service;
use DateTimeImmutable;
use IntlDateFormatter;
class Format
{
public function localDate(string $valor, string $format, bool $print = false): string
{
$date = new DateTimeImmutable($valor);
$formatter = new IntlDateFormatter('es_ES');
if ($format == null) {
$format = 'DD [de] MMMM [de] YYYY';
}
$formatter->setPattern($format);
return $formatter->format($date);
}
public function pesos(string $valor): string
{
return '$' . number_format($valor, 0, ',', '.');
}
}