-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datetime field: impossible to select time format 17:10:02 #758
Comments
This issue doesn't have a lot of effect on the actual time output format because the "Time Output Format" field value is not actually saved as part of the field config and it's the "Date/Time Output Format Code" field that has an effect, and this field is updated correctly from the selection in Time Output Format. But the Date/Time Output Format Code field is shown collapsed so there can be confusion because the visible Time Output Format can show a value that is not actually in effect. The problem part is here, where |
Possible fix - not sure if there's something more optimal: $matches = array();
foreach($wdt->getTimeFormats() as $format) {
$timeFormatted = $wdt->formatDate($date, $format);
$f->addOption($format, $timeFormatted);
if(strpos($field->get('dateOutputFormat'), $format) !== false) $matches[] = $format;
}
if(!empty($matches)) {
usort($matches, function($a, $b) {
return strlen($b) - strlen($a);
});
$f->value = reset($matches);
} |
…02" time format in FieldtypeDatetime
Thanks, that's a good find. I've pushed an update to correct it. |
I like what you did there - I haven't seen that before. |
Short description of the issue
One of the time output formats for Datetime fields is "17:10:02". But it's impossible to select this format in the dropdown as it is changed to the "17:10" format after the field is saved.
Setup/Environment
The text was updated successfully, but these errors were encountered: