1

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?

2

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.

1

Currently not possible as it's hard-coded into Craft.

Probably worth adding as a feature request, though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.