This topic is locked

how to change date format in a grid

11/29/2023 3:50:11 PM
PHPRunner General questions
I author

hello, i want to change the dates in a grid to this format: dd-mm-yyyy
for example 9-7-1956 should be 09-07-1956
in which event should I write which code? Thanks.

admin 11/29/2023

Use 'View as' type Custom and write your own code there that formats the date in the required way:

I author 11/30/2023

Hello Sergey, before I post a message on the forum, I will first search here in the forum, but also in the help files of phprunner if there is anything I could use. Of course I had already found the link you gave me. I was actually looking for a piece of code (Java script or PHP) with which I can see the correct date notation in a grid (code for example in the before display event). Still, thanks for your help.

cristi 11/30/2023

As admin said you can do it in view as custom:
The object oriented way:

$date = DateTime::createFromFormat('d-m-Y', $value);
$value= $date->format('d-m-Y');
I author 12/1/2023

Thank you!, this is exactly what I was looking for.