Page 1 of 1
dd mm yyyy date format - how?
Posted: 2024-04-15 15:21
by graham
Hi, I'm using the date picker in 24:12 and and need UK style dd mm yyyy format. But at the moment it's going to my database (as shown in phpMyAdmin) as yyyy mm dd. I can see the option of UK short date form but even if I choose that, it's still going into the database as yyyy mm dd. Perhaps this isn't an AppGini thing? - perhaps it's phpMyAdmin or MySQL itself? Any help appreciated.
Re: dd mm yyyy date format - how?
Posted: 2024-04-15 15:31
by graham
Sorry, I should have persisted with my research? I think the answer is that mysql is the problem and I have to retrieve it as I want to by using SELECT DATE_FORMAT(your_date_column, '%d %m %Y') AS formatted_date FROM your_table; if that's wrong, please let me know! Thanks.
Re: dd mm yyyy date format - how?
Posted: 2024-04-16 16:19
by jsetzer
Unless you reconfigure your MySQL Server or database, dates will always be stored in
yyyy-mm-dd format, by default.
This means we have to change output format when retrieving from database (as you have already mentioned before) or when displaying date values in UI.
Helpful AppGini function in PHP:
Code: Select all
$db_date = '2024-04-16';
$d_formatted = app_datetime($db_date, 'd');
That useful function already takes app-configuration into consideration. It returns the date as string according to your locale settings, defined in the project itself.
Hope this helps.