<![CDATA[ How to change date notation to other (local) language - My Forums]]> https://forums.modx.com/thread/?thread=71553 <![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-554459 Quote from: mdeuerlein at Aug 01, 2015, 07:55 PM
For me with MODX 2.3.5-pl

in "system settings > core > locale"
setting the value to "de_DE"

works fine for german language settings with strftime()

For me as well on version 2.5.8]]>
flipflop1974 Oct 12, 2017, 09:08 AM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-554459
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-529346 MODX 2.3.5-pl

in "system settings > core > locale"
setting the value to "de_DE"

works fine for german language settings with strftime()]]>
mdeuerlein Aug 01, 2015, 07:55 PM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-529346
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-527329
$eventName = $modx->event->name;
if($modx->context->get('key') == 'mgr' || $eventName != 'OnHandleRequest') { return ''; }

$hostname = $_SERVER['HTTP_HOST'];
switch($hostname) {
    case 'mywebsite.de':
        $modx->switchContext('deutsch');
        setlocale(LC_ALL,$modx->context->getOption('locale', null, 'default'));
    break;
}  


I have no idea why the context setting is not being picked up in the first place, but adding this line fixed it for me..]]>
suikerzout Jun 23, 2015, 03:44 AM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-527329
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-520250
locale in system settings > doesn't work
locale in context settings > doesn't work

Snippet :
<?php
$locale = $modx->context->getOption('locale', null, 'default');
setlocale(LC_ALL,$locale.'.UTF-8');


works fine ([[!setlocale]] call in header)]]>
johnxx Feb 08, 2015, 12:45 PM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-520250
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-517134
<?php
//langDate
//Converts date format
//Use: [[langDate? &date=`[[*publishedon]]`]]
  
$modx->lexicon->load('core:default');

$month = strtolower(date('F', strtotime($date) ));
$day = strtolower(date('l', strtotime($date) ));


$dy = date("N", strtotime($date));


$fullday = $modx->lexicon($day); //Monday in current language

$month = $modx->lexicon($month);//May in current language
  
$day = date("d", strtotime($date)); // 13

$year = date("Y", strtotime($date)); // 2014
  


return $fullday.', '.$day.'. '.$month.' '.$year;
]]>
the_spy15 Dec 20, 2014, 12:51 PM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-517134
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-511003
"Puno ti hvala, ovo je super stvar."]]>
aximotorr Sep 22, 2014, 01:51 PM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-511003
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-503021
Setting the system setting to
nl_NL
did not work for a recent project (LEMP) but
nl_NL.UTF-8
did the trick]]>
Magnatron Jul 14, 2014, 06:18 AM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-503021
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-492456 Quote from: BobRay at Sep 30, 2013, 09:34 AM
FYI: date() doesn't respect the locale setting -- strftime() does. Using strftime() will give you the language-appropriate month and day names.

You can always call setlocale() just before calling strftime().



“When you know better you do better.” smiley
P.S. Thanks for tip.]]>
tomek Mar 12, 2014, 08:14 AM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-492456
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-492455
<?php
//setDateLT
//Converts date format
//Use: [[setDateLT? &date=`[[*publishedon]]`]]
 
// months in Lithuanian
$months = array(1 => "sausio",		//January
                2 => "vasario",		//February
                3 => "kovo",		//March
                4 => "balandžio",	//April
                5 => "gegužės",		//May
                6 => "birželio",	//Jun
                7 => "liepos",		//July
                8 => "rugpjūčio",	//August
                9 => "rugsėjo",		//September
                10=> "spalio",		//October
                11=> "lapkričio",	//November
                12=> "gruodžio");	//December
   
$mj = date("n", strtotime($date));
   
// days in Lithuanian
$days = array(1 => "pirmadienis", // Monday
            2 => "antradienis",      //Thuesday
            3 => "trečiadienis",     //Wensday
            4 => "ketvirtadienis",    //Thursday
            5 => "penktadienis",        // Friday
            6 => "šeštadienis",       //Saturday
            7 => "sekmadienis");   //Sunday
   
$dy = date("N", strtotime($date));
   
//Get vars
$fullday = $days[$dy]; // For example Monday
$month = $months[$mj]; // For example January
$day = date("d", strtotime($date)); //For example 28
$year = date("Y", strtotime($date));// For example 2012
   
//display date format example:
//2014 m. kovo 11 d.
 
return $year.' m. '.$month.' '.$day.' d. ';
]]>
vytukas Mar 12, 2014, 08:00 AM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-492455
<![CDATA[Re: How to change date notation to other (local) language]]> https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-479015
You can always call setlocale() just before calling strftime().]]>
BobRay Sep 30, 2013, 04:34 AM https://forums.modx.com/thread/71553/how-to-change-date-notification-to-other-local-language?page=2#dis-post-479015