mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 09:02:41 +00:00
bb8af5a62c
• Created Db/SQLite3/CustomFunctions to house the dateFormat custom function and potentially others in the future. • Fixed a typo in Db/SQLite3/Driver
21 lines
No EOL
697 B
PHP
21 lines
No EOL
697 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
namespace JKingWeb\NewsSync\Db\SQLite3;
|
|
|
|
class CustomFunctions {
|
|
// Converts from SQLite3's date format to a specified standard date format.
|
|
public static function dateFormat(string $format, string $date): string {
|
|
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $date, 'UTC');
|
|
|
|
$format = strtolower($format);
|
|
switch ($format) {
|
|
case 'unix': return (string)$date->getTimestamp();
|
|
break;
|
|
case 'rfc822':
|
|
case 'http': return $date->format(\DateTime::RFC822);
|
|
break;
|
|
case 'iso8601':
|
|
default: return $date->format(\DateTime::ISO8601);
|
|
}
|
|
}
|
|
} |