Date format strings in Results list

wallaby9

Member
I know this has been raised and answered before (https://dadabik.com/forum/index.php?threads/date-format-in-list.23268/) but this didn't provide a solution for me. I have RTFM, in the form of config.php and google searches.

The three available date formats for the Results list appear to be "latin", "numeric_english" and "literal_english".

None of those appear to provide what I need which is "YYYY-MM-DD".

In fact, more important is for my timestamp fields to appear as "YYYY-MM-DD HH:MM:SS".

They are fine in my Edit pages. Just wrong in the Results lists.

Best is "latin" as it gives me "English" style dates ("DD-MM-YYYY") but these are almost as much the devil's work as American dates.

Can it be done, other than by a custom display function with the attendant horrendous performance hit?

Ideally we could use a string like the date format in the Edit page, no?

Screenshots below...

Thank you.



Bad:

1658233548788.png

Good: (except the layout of the "+" button :) )

1658233585991.png



Your current DaDaBIK version​

You are using DaDaBIK version 11.6-Elba enterprise, installed on 14-06-2022 (installation code: 179456288336fd5460), the latest version of DaDaBIK is 11.6-Elba released on 14-06-2022

You are running the latest release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enteprise to Platinum) please contact us.

System info​

PHP Version: 7.4.29

mysql version: 5.5.5-10.3.34-MariaDB-0ubuntu0.20.04.1

Web server: LiteSpeed

Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36
 

eugenio

Administrator
Staff member
Hello,
a custom display function doesn't cause a "horrendous performance hit" :)

Anyway, the three format available are the ones you saw in config, if you want you can also change format_date and format_date_time in /include/general_functions.php but you have to re-apply your changes when you upgrade dadabik.

You can also propose in the feature request forum an additional (4th) format.

Best,
 

wallaby9

Member
Hello,
a custom display function doesn't cause a "horrendous performance hit" :)

Anyway, the three format available are the ones you saw in config, if you want you can also change format_date and format_date_time in /include/general_functions.php but you have to re-apply your changes when you upgrade dadabik.

You can also propose in the feature request forum an additional (4th) format.

Best,

I take that back if that's not the case! Apologies. I may be thinking of calculated fields? Certainly one of the options you can take to modify the display of a field in the results list causes it to take several times as long as it normally takes to load the list.. let me think.

Thanks, I will make a feature suggestion 👍
 

eugenio

Administrator
Staff member
Calculated fields are not used the results grid.
The execution time of custom formatting functions all depends on the PHP execution time of function itself, if you just change the color of a value, it probably takes 0.0000xxx seconds, if for each record you apply a complicated formula that take seconds to be executed (even outside dadabik), this obviously has an impact.
 

wallaby9

Member
In case anyone else is wanting to change the format in which dadabik displays dates, to the only date format that make any sense to me, the changes I made which appear to work are these.

In dadabik/include/general_functions.php, find these lines (in my file they are lines 299 and 300):

case "latin": $date = $temp_ar[2].$date_separator.$temp_ar[1].$date_separator.$temp_ar[0];

and change [2] to [0], and [0] to [2].

It should then look like this:

case "latin": $date = $temp_ar[0].$date_separator.$temp_ar[1].$date_separator.$temp_ar[2];

Then find the following lines (in my file lines 325 and 326):

case "latin": $date = $temp_2_ar[2].$date_separator.$temp_2_ar[1].$date_separator.$temp_2_ar[0].$time_part;

and do the same thing, so it looks like this:

case "latin": $date = $temp_2_ar[0].$date_separator.$temp_2_ar[1].$date_separator.$temp_2_ar[2].$time_part;

Save the file, and test with a dadabik page that shows dates & times. They should display like this:

1658438120480.png

Remember that you will have to reapply these changes when you upgrade or reinstall dadabik because general_functions.php will be overwritten.
 

wallaby9

Member
Calculated fields are not used the results grid.
The execution time of custom formatting functions all depends on the PHP execution time of function itself, if you just change the color of a value, it probably takes 0.0000xxx seconds, if for each record you apply a complicated formula that take seconds to be executed (even outside dadabik), this obviously has an impact.

Having checked, there were two functions I've been playing with:

function dadabik_iso_date_format($the_date) { return date_format(date_create($the_date), DATE_ISO8601); }

function dadabik_lpad_4($in) { return str_pad($in, 4, "0", STR_PAD_LEFT); }

To display 413 records as a Results list without using these functions takes around 0.25s.

If I use the first one on a date field, loading the same page takes around 2.5 seconds.

If I use the second on an ID field, it's about 2 seconds.

So with 2 date fields and an ID field in the Results list, that's about 7 seconds to load the same page.

This is obviously an edge case (many of my cases are :) ). I know I could improve the performance tenfold if I changed my results per page to 100 rather than 1000 but I need to have the entire dataset scrollable. Anyway the date format function is now moot because of my previous post in this topic, and I've decided I can live without the left padding for now :)

None of the above implies criticism of the software! As always I appreciate your help.
 
Top