Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Displaying a date in question text, according to user-selected language

  • eirikat
  • eirikat's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 10 months ago - 8 years 10 months ago #119989 by eirikat
Hi,

I'm developing a survey in several languages, and would like to include today's date in one of the questions. Currently, I do this using Expression Manager:
Code:
{date("l F n\t\h, o")} // Output: Tuesday May 5th, 2015

However, this way of formatting the date has several shortcomings:
  • The "th" doesn't work for the first, second and third of each month
  • For other languages than English, the format is inappropriate. For example, in Norwegian, I would have liked to write "Tirsdag 5. mai, 2015", which requires setting the nb_NO locale. Somehow, this is not achieved by changing the survey language. In fact, not even the survey's standard language affects this (standard language is set to Norwegian, but English is displayed).
Is there a way of linking the locale used for formatting dates in a question, to the language selected by the survey respondent? And, subsequently, how might I include special cases to present dates like 1st, 2nd and 3rd?

Thanks in advance for your help!
Last edit: 8 years 10 months ago by eirikat. Reason: Text formatting
The topic has been locked.
More
8 years 10 months ago #120155 by jazzy
I think what you are looking for is

{date("l F jS, o")}

j = Day of the month without leading zeros
S = English ordinal suffix for the day of the month, 2 characters

As far as the language question I'm just guessing here but these functions are not Lime Survey functions but PHP functions. As such, I doubt you can change it by changing any settings in limesurvey.

Cheers,
Jeff
The following user(s) said Thank You: eirikat
The topic has been locked.
  • eirikat
  • eirikat's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 10 months ago #120233 by eirikat
Thank you, jazzy, this works perfectly in English. I think you are right about the language settings for time being set in PHP somewhere. I'll see if I can figure out a workaround.

Cheers,

Eirik
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose