Jump to content

Recommended Posts

Thanks...

I might be using it wrong, but adding setlocale(LC_ALL, 'no_NO'); did not do the trick.

I'm not sure if the host has installed the Norwegian language but it is a Norwegian host with it's servers located in Norway.

 

On top of my index i added setlocale(LC_ALL, 'no_NO'); as the first PHP code.

Also tested to add it just to the code where i want it to effect...

Link to comment
https://forums.phpfreaks.com/topic/269976-date/#findComment-1388110
Share on other sites

If you have access to a command line on the server, run locale -a. It could be that the locale is named slightly differently, or you can generate that locale. If you don't have access to check/generate it yourself, I don't see why the host wouldn't be happy to do it for you.

Link to comment
https://forums.phpfreaks.com/topic/269976-date/#findComment-1388139
Share on other sites

Should the host refuse to install Norwegian locale support, for whatever silly reason (those non-vikings :P ), then you can use the following code to automatically translate it for you:

$days ('monday' => 'Mandag',
   'tuesday' => 'Tirsdag',
   'wednesday' => 'Onsdag',
   'thursday' => 'Torsdag',
   'friday' => 'Fredag',
   'saturday' => 'Lørdag',
   'sunday' => 'Søndag');
$date = str_ireplace (array_keys ($days), array_values ($days), $date);

Link to comment
https://forums.phpfreaks.com/topic/269976-date/#findComment-1388234
Share on other sites

setlocale returns false when it can't set a certain locale. You can also pass multiple possibilities. Try:

 

setlocale(LC_TIME, 'no_NO', 'no', 'nor', /* Windows: */ 'Norwegian_Norway.1252', /* Use the system locale */ '') or exit('locale does not exist');

Edited by ignace
Link to comment
https://forums.phpfreaks.com/topic/269976-date/#findComment-1388238
Share on other sites

or use

 

$rss = $row['dato'];
$dayNamesb = array("søndag", "mandag", "tirsdag", "onsdag",
"torsdag", "fredag", "lørdag");
$monthNamesb = array("januar", "februar", "mars", "april", "mai", "juni",
"juli", "august", "september", "oktober", "november",
"desember");
$dato = $dayNamesb[date('w', strtotime($rss))] . ", " . date('d', strtotime($rss)) . " " .
$monthNamesb[(date('m', strtotime($rss))-1)] . " " . date('Y', strtotime($rss));

echo $dato;

 

this wil give you something like søndag 29 oktober 2012

Edited by johnnyd1963
Link to comment
https://forums.phpfreaks.com/topic/269976-date/#findComment-1388244
Share on other sites

fesan you have to try all possible locale strings until you're successful. The standard NO_no rarely works.

 

"Norwegian (Bokmål)_Norway.1252" or "norwegian-nynorsk" or "no_NO.UTF-8"

 

or

 

setlocale(LC_ALL, 'no_NO.ISO8859-1', 'nb_NO.ISO-8859-1', 'no', 'nb', 'nob-NO', 'no_NO', 'nb_NO', 'nor', 'norwegian', 'bokmal');

 

​Lycka till =)

Edited by silkfire
Link to comment
https://forums.phpfreaks.com/topic/269976-date/#findComment-1388521
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.