Shorten Months Displayed (e.g., November to Nov)

us3rus3r New
edited November 2015 in Vanilla 2.0 - 2.8

Is there a way I can shorten the months displayed in the theme? Without modifying the core vanilla files? I assume this can be done in the definitions file in locales\skeleton\definitions.php or locales\skeleton\other_definitions.php

Maybe even conf/locale.php

For example

November 15 to Nov 15

Something like this? But with out modifying the core files.

Oliver_Chevet's post at http://vanillaforums.org/discussion/11275/dates-localization/p1
Step 1 : create arrays for month and day names in the standard locale

In Garden/applications/dashboard/locale/en-CA/definitions.php look for :

$Definition['Date.DefaultDateTimeFormat'] = '%B %e, %Y %l:%M%p';

$Definition['Date.MonthNames'] = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$Definition['Date.MonthShortNames'] = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

Step 2 : Modify Date_format to use those arrays

Modify library/core/class.format.php to use those arrays

Thanks again

Comments

  • It's only a translation task.

    Set this in your /conf/locale.php: $Definition['Date.DefaultDateTimeFormat'] = '%b %e, %Y %l:%M%p';

    See http://php.net/manual/en/function.strftime.php if you are interested in what is happening here

  • Thanks for the response @R_J . It doesn't seem to work. I also changed p to P to test, and still no changes.
    Should I delete the .ini files in cache?

  • Added these and now it works

    $Definition['Date.DefaultFormat'] = '%b %e, %Y';
    $Definition['Date.DefaultDayFormat'] = '%b %e';
    $Definition['Date.DefaultYearFormat'] = '%b %Y';

  • jackmaessenjackmaessen ✭✭✭
    edited November 2015

    try these ones in conf/locale.php and modify it to your own needs

    $Configuration['Date']['DateCreated'] = '%a %e %b %H:%M';
    $Configuration['Date']['PostEdited'] = '%a %e %b %H:%M';
    $Definition['Date.DefaultFormat'] = '%a %e %b, %Y';
    $Definition['Date.DefaultDayFormat'] = '%a %e %b %H:%M';
    $Definition['Date.DefaultYearFormat'] = '%a %e %b %Y';
    $Definition['Date.DefaultTimeFormat'] = '%a %e %b %H:%M';
    $Definition['Date.DefaultDateTimeFormat'] = '%a %e %b, %Y %l:%M%p %H:%M';
    
Sign In or Register to comment.