From 2f256efa9b0b7012c05bdf606583aa5e6c2c7747 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 25 May 2023 11:22:45 +0200 Subject: [PATCH] Add `machine` output type to `{time}` This will output a machine-readable version of the datetime, i.e. the ISO-8601 format. This is intended as a replacement for `{$foo|date:'c'}`. --- .../template/plugin/TimeFunctionTemplatePlugin.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wcfsetup/install/files/lib/system/template/plugin/TimeFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/TimeFunctionTemplatePlugin.class.php index 85fc14e016..6c411ada5d 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/TimeFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/TimeFunctionTemplatePlugin.class.php @@ -16,6 +16,7 @@ use wcf\system\WCF; * {time time=$timestamp} * {time time=$timestamp type='plainTime'} * {time time=$timestamp type='plainDate'} + * {time time=$timestamp type='machine'} * {time time=$timestamp type='custom' format='Y-m-d'} * * @author Tim Duesterhus, Marcel Werk @@ -82,6 +83,8 @@ final class TimeFunctionTemplatePlugin implements IFunctionTemplatePlugin ], $locale ); + case 'machine': + return $dateTime->format(\DateTimeInterface::ATOM); case 'custom': return $dateTime->format($tagArgs['format']); default: -- 2.20.1