For example: 2022-03-11
If someone wants to display the German date:
In the view, at the top under "Page Blocks", look for "Text Node" in the table list and paste the line with the date (for example the line: "Model.datum").
Insert in the "Text Node" as text content:
{date:d.m.Y$(var:Model.datum)}
is endformat: 11.03.2022
Finished :-)
Hi Fredolino,
Great, this is still working in CF8 :-)
Now I have tried the {date:d F Y} format which is enough for my needs, but i get the month's name in english instead French expected.
Any advice ?
you need PHP code to return the month in French:
setlocale(LC_TIME, 'fr_FR.UTF-8');
return strftime('%d %B %Y'); // Outputs: 25 janvier 2025
then use {var:php_action_name} where you want to show the result
Hi Fredolino,
I tested your hint today, but unfortunately it doesn't work for me.
My entry under "Content" is: {date:d.m.Y$(var:Date)}The table output shows:01.02.2025$(312amSat, 01 Feb 2025 10:49:15 +0000:Satam2831231302)The correct date would be: 17.12.2024
I would be very grateful for a hint.
if you need 17.12.2024 then you should just use {date:d.m.Y}
the solution posted above if for v7 only and will not work in v8
if you need to pass a dynamic value to format then you need either to wait for the next update and use this syntax:
{date:Y-m-d={var:row.Datum}}
where {var:row.Datum} is the dynamic date value to be formatted
OR you can format it using a PHP action inside the column instead of the Text node you have now:
echo date("Y-m-d", $this->get("row.Datum"));
You may also return that value instead of "echo" and use it in a Text node as {var:php_action_name}
Hi Max,thanks for your help.But I get an error:
date(): Argument #2 ($timestamp) must be of type ?int, string given
Now I found a solution:
in the PHP action:
$timestamp1 = strtotime($this->get("row.Datum"));
echo date("d.m.Y", $timestamp1);
correct, I forgot the need for strtotime