View/format the date in table list

How to format dates in a ChronoForms table list.

Overview

The issue occurs when dates from a database display in a raw format instead of the desired localized or custom format.
Use a PHP action to convert the date string with strtotime and then format it with the date function. Insert the result into your table using the appropriate variable.

Fr Fredolino 11 Sep, 2022
Answer
3 Likes
When the Table list is based on a Read Data, sometimes the date is shown as formatted in the database.
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 :-)
Bi BigStef 27 Jan, 2025

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 ?

Max_admin Max_admin 27 Jan, 2025
1 Likes

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

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ga gallusala 01 Feb, 2025

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.

Max_admin Max_admin 02 Feb, 2025

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

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ga gallusala 02 Feb, 2025

I tried it, but I only get today's date.

Max_admin Max_admin 02 Feb, 2025

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}

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ga gallusala 03 Feb, 2025

Hi Max,thanks for your help.But I get an error:

date(): Argument #2 ($timestamp) must be of type ?int, string given

ga gallusala 03 Feb, 2025
1 Likes

Now I found a solution:

in the PHP action:

$timestamp1 = strtotime($this->get("row.Datum"));
echo date("d.m.Y", $timestamp1);
Max_admin Max_admin 03 Feb, 2025

correct, I forgot the need for strtotime

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.