jikan-rest/app/IsoDateFormatter.php
2023-05-21 11:14:34 +01:00

20 lines
379 B
PHP

<?php
namespace App;
trait IsoDateFormatter
{
protected function formatIsoDateTime(string $d): string
{
$dt = explode('-', $d);
return (new \DateTime())
->setDate(
$dt[0] ?? date('Y'),
$dt[1] ?? 1,
$dt[2] ?? 1
)
->setTime(0, 0)
->format(DATE_ATOM);
}
}