From ba62e0c69625aceb31a730b78c08c2fe116d521c Mon Sep 17 00:00:00 2001 From: Tom Benevides Date: Thu, 14 Oct 2021 20:57:16 -0400 Subject: [PATCH] Setting date format for Postgres in an adapter --- src/Adapters/PgsqlAdapter.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/Adapters/PgsqlAdapter.php diff --git a/src/Adapters/PgsqlAdapter.php b/src/Adapters/PgsqlAdapter.php new file mode 100644 index 0000000..47e44b1 --- /dev/null +++ b/src/Adapters/PgsqlAdapter.php @@ -0,0 +1,22 @@ + 'YYYY-MM-DD HH24:MI:00', + 'hour' => 'YYYY-MM-DD HH24:00:00', + 'day' => 'YYYY-MM-DD', + 'month' => 'YYYY-MM', + 'year' => 'YYYY', + default => throw new Error('Invalid interval.'), + }; + + return "to_char({$column}, '{$format}')"; + } +}