Customize timestamp

More
4 years 1 month ago #100559 by dmoci
dmoci created the topic: Customize timestamp
Hi,
is it possible to customize the timestamp?

I need to be able to analyze my data by year, month and weekday to something like
13-03-2
(standing for 2013, March, Tuesday).
It would be best to have the three values as separate variables in the data set.

For privacy reasons I cannot save the whole timestamp because every more exact time information (day, hour, minute...) would allow for identifying individual people. I have the impression that the Expression Manager could help me, but I am not an experienced programmer and so don't really understand how to use that.

Help is very much appreciated! Thanks in advance.
dmoci

Please Log in to join the conversation.

More
4 years 1 month ago #100561 by mfaber
mfaber replied the topic: Customize timestamp
It's not a big problem to extract these data from an existing timestamp. You could use the following function {date("Y-m-w",strtotime(yourdate))}.

Where does this date come from? Is it collected using a date/time question? Or is it the date the survey was taken?

To be able to lead you in the right direction: Would it be ok to collect the full date, extract the components you need and only export those? Or do you need, for data protection reasons, a solution where only these data are COLLECTED? And: what is your Limesurvey version?

Please Log in to join the conversation.

More
4 years 1 month ago #100562 by dmoci
dmoci replied the topic: Customize timestamp
Thanks for your quick reply, mfaber! Your last assumption is right: For data protection reasons I may only COLLECT the year/month/weekday-component of the timestamp. I may not save any more information in the data set. So I probably would have to call the function you specified for extracting these components from the timestamp before writing the data to the data set (however this can be done). The date I am interested in is the date the survey is taken. How this is collected (timestamp or a somehow hidden date/time-question) is not important to me as long as it is collected automatically (i.e. no user input).
I am using the latest version of limesurvey.

Please Log in to join the conversation.

More
4 years 1 month ago #100563 by mfaber
mfaber replied the topic: Customize timestamp
ok, cool...
You'll create a new question, equation type. In the question text you'll put
{date("Y-m-w",strtotime("now"))}.

It'll show you todays "date" as "13-10-2". The 2 is for wednesday cause it starts counting from 0. This information will then be collected automatically and saved much like a user response in the database.

Test it...if it works as expected you can also hide the question. Lastly, when activating the survey have the survey timestamp, ip-address etc. deactivated so no user identifiable information is collected. You should be good to go.
The following user(s) said Thank You: dmoci

Please Log in to join the conversation.

More
4 years 1 month ago #100564 by mfaber
mfaber replied the topic: Customize timestamp
Oh yes...should you require any other date components...such as the week number, month, etc., you can find the whole list of available options here:
php.net/manual/en/function.date.php
The following user(s) said Thank You: dmoci

Please Log in to join the conversation.

More
4 years 1 month ago #100570 by dmoci
dmoci replied the topic: Customize timestamp
This works perfect, just as I need it. Thanks a lot!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!