In control panel, specifically when displaying elements table under any section, postDate and expiryDate values are in relative format i.e. Today, Yesterday, Monday, Wednesday, ..etc.
How can I disable that and display them in dates only?
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communityIn control panel, specifically when displaying elements table under any section, postDate and expiryDate values are in relative format i.e. Today, Yesterday, Monday, Wednesday, ..etc.
How can I disable that and display them in dates only?
Until this feature get implemented, I think I'll go with the following workaround that I'm using right now. It's based on getEntryTableAttributeHtml hook where I reformat the date value to match the user locale preferences.
public function getEntryTableAttributeHtml(EntryModel $entry, $attribute)
{
if ($attribute == 'postDate')
{
$localeData = craft()->i18n->getLocaleData(craft()->language);
$dateFormatter = $localeData->getDateFormatter();
$format = $dateFormatter->getDatepickerPhpFormat();
return ($entry->postDate ? $entry->postDate->format($format) : '');
}
}
or simply
public function getEntryTableAttributeHtml(EntryModel $entry, $attribute)
{
if ($attribute == 'postDate')
{
return $entry->postDate;
}
}
which will return the date in Y-m-d format regardless of locale.
Currently not possible as it's hard-coded into Craft.
Probably worth adding as a feature request, though!