WebFaction
Community site: login faq

In a PHP app I am using setlocale to change the locale as chosen by the user. An example of the relevant code is as follows:

setlocale(LC_TIME, "de", "de_DE");

However, the chosen locale is not respected when displaying dates using strftime().

Are there additional steps that need to be done when setting the locale, or does WebFaction not support this?

asked 25 Jun '14, 04:10

Jonathan Head
3157
accept rate: 100%


I figured out the problem - I was passing in a variable representing the locale, and not a string directly, i.e.

$locale = "de";
setlocale(LC_TIME, $locale);

This, apparently, does not work, and once I passed in the value directly the setting was correctly interpreted.

permanent link

answered 26 Jun '14, 03:31

Jonathan Head
3157
accept rate: 100%

We support setlocale. I'm not sure why it's not working for you.

I set up a test page with the following code...

<?php
setlocale(LC_TIME, "de", "de_DE");
echo strftime("%A");

... and the page produces the name of the current day, in German as expected.

If it's still not working for you, feel free to open a support ticket and we'll be happy to look into it further for you.

permanent link

answered 25 Jun '14, 23:09

seanf
12.2k42136
accept rate: 37%

edited 25 Jun '14, 23:09

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×264
×5

question asked: 25 Jun '14, 04:10

question was seen: 8,779 times

last updated: 26 Jun '14, 03:31

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM