- Posts: 16
- Thank you received: 3
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
- Topic Author
- Offline
- New Member
Less
More
8 years 10 months ago - 8 years 10 months ago #119989
by eirikat
Displaying a date in question text, according to user-selected language was created 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:
However, this way of formatting the date has several shortcomings:
Thanks in advance for your help!
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).
Thanks in advance for your help!
Last edit: 8 years 10 months ago by eirikat. Reason: Text formatting
The topic has been locked.
- jazzy
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 1
8 years 10 months ago #120155
by jazzy
Replied by jazzy on topic Displaying a date in question text, according to user-selected language
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
{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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 3
8 years 10 months ago #120233
by eirikat
Replied by eirikat on topic Displaying a date in question text, according to user-selected language
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
Cheers,
Eirik
The topic has been locked.