Would it be possible, in a future release of Piwigo, to include a setting so that we can change the date format? I am in the USA, and my audience is primarily in the USA, and so I would prefer to display dates in the customary format for the USA which places the month first, e.g. January 16, 2024, rather than the European format which puts the day first, e.g. 16 January 2024.
I feel like such an option would make sense right beneath the "Week starts on" option on the general configuration page.
Offline
I ran into this exact same issue myself. This was asked in 2013 in this post (https://piwigo.org/forum/viewtopic.php?id=21507). There is no configuration option to change the date, but the function that generates it is "format_date" and it's very easy to modify. At the time of this post, this function is in the file "piwigo/include/functions.inc.php". Simply re-arrange the lines as you like. Code begins around line 794 in the file. Here's mine:
function format_date($original, $show=null, $format=null)
{
global $lang;
$date = str2DateTime($original, $format);
if (!$date)
{
return l10n('N/A');
}
if ($show === null || $show === true)
{
$show = array('day_name', 'day', 'month', 'year');
}
// TODO use IntlDateFormatter for proper i18n
$print = '';
// Weekday
if (in_array('day_name', $show))
$print.= $lang['day'][ $date->format('w') ].' - ';
// Month
if (in_array('month', $show))
$print.= $lang['month'][ $date->format('n') ].' ';
// Day
if (in_array('day', $show))
$print.= $date->format('j').', ';
// Year
if (in_array('year', $show))
$print.= $date->format('Y').' ';
if (in_array('time', $show))
{
$temp = $date->format('H:i');
if ($temp != '00:00')
{
$print.= $temp.' ';
}
}
return trim($print);
}
If you have the option "Show the date period associated with each album..." under the menu "Configuration > Options > Display Tab", then you'll probably want to change the function just below it called "format_fromto" in the same functions.inc.php file. Here's my hacked version:
function format_fromto($from, $to, $full=false)
{
$from = str2DateTime($from);
$to = str2DateTime($to);
// Dates match. Return only 1 of them.
if ($from->format('Y-m-d') == $to->format('Y-m-d'))
{
return format_date($from);
}
// Dates do not match. Return a range.
else
{
$from_str = format_date($from);
$to_str = format_date($to);
$from_str = substr($from_str, strpos($from_str, " - ") + 3);
$to_str = substr($to_str, strpos($to_str, " - ") + 3);
return l10n('%s to %s', $from_str, $to_str);
}
}
I don't know if it's possible, but a much nicer way to update these two functions would be to use a Personal plugin or such. But...I don't know how to do that (replace one function with another through a plugin) so I'm stuck using this method.
Hope this helps.
Offline