diff --git a/site/plugins/admin/app/Controllers/SettingsController.php b/site/plugins/admin/app/Controllers/SettingsController.php index 5d75dbb6..735d72ed 100644 --- a/site/plugins/admin/app/Controllers/SettingsController.php +++ b/site/plugins/admin/app/Controllers/SettingsController.php @@ -91,6 +91,8 @@ class SettingsController extends Controller 'plugins/admin/views/templates/system/settings/index.html', [ 'timezones' => Date::timezones(), + 'date_formats' => $this->dateFormats(), + 'date_display_format' => $this->displayDateFormats(), 'cache_driver' => $cache_driver, 'locales' => $locales, 'entries' => $entries, @@ -149,4 +151,44 @@ class SettingsController extends Controller return $response->withRedirect($this->router->pathFor('admin.settings.index')); } + + /** + * Return date formats allowed + * + * @return array + */ + public function dateFormats() + { + $now = new \DateTime(); + + $date_formats = [ + 'd-m-Y H:i' => $now->format('d-m-Y H:i'), + 'Y-m-d H:i' => $now->format('Y-m-d H:i'), + 'm/d/Y h:i a' => $now->format('m/d/Y h:i a'), + 'H:i d-m-Y' => $now->format('H:i d-m-Y'), + 'h:i a m/d/Y' => $now->format('h:i a m/d/Y'), + ]; + + return $date_formats; + } + + /** + * Return display date formats allowed + * + * @return array + */ + public function displayDateFormats() : array + { + $now = new \DateTime(); + + $date_formats = [ + 'F jS \\a\\t g:ia' => $now->format('F jS \\a\\t g:ia'), + 'l jS \\of F g:i A' => $now->format('l jS \\of F g:i A'), + 'D, d M Y G:i:s' => $now->format('m/d/Y h:i a'), + 'd-m-y G:i' => $now->format('d-m-y G:i'), + 'jS M Y' => $now->format('jS M Y'), + ]; + + return $date_formats; + } } diff --git a/site/plugins/admin/lang/en_US.yaml b/site/plugins/admin/lang/en_US.yaml index 5e7fe6ad..93658cf8 100755 --- a/site/plugins/admin/lang/en_US.yaml +++ b/site/plugins/admin/lang/en_US.yaml @@ -101,6 +101,7 @@ admin_cache_lifetime: "Cache lifetime" admin_cache_prefix: "Cache prefix" admin_charset: "Charset" admin_date_format: "Date format" +admin_date_display_format: "Display date format" admin_errors_display: "Display errors" admin_locale: "Locale" admin_entry_main: "Main entry" diff --git a/site/plugins/admin/views/templates/system/settings/index.html b/site/plugins/admin/views/templates/system/settings/index.html index 256cc814..82b41d1f 100644 --- a/site/plugins/admin/views/templates/system/settings/index.html +++ b/site/plugins/admin/views/templates/system/settings/index.html @@ -83,7 +83,19 @@
- + +
+
+ +