Welcome, Guest
Username: Password: Remember me

TOPIC: Customize timestamp

Customize timestamp 9 months 2 weeks ago #100559

  • dmoci
  • dmoci's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
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
The administrator has disabled public write access.

Customize timestamp 9 months 2 weeks ago #100561

  • mfaber
  • mfaber's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 82
  • Thank you received: 21
  • Karma: 4
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?
The administrator has disabled public write access.

Customize timestamp 9 months 2 weeks ago #100562

  • dmoci
  • dmoci's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
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.
The administrator has disabled public write access.

Customize timestamp 9 months 2 weeks ago #100563

  • mfaber
  • mfaber's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 82
  • Thank you received: 21
  • Karma: 4
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 administrator has disabled public write access.
The following user(s) said Thank You: dmoci

Customize timestamp 9 months 2 weeks ago #100564

  • mfaber
  • mfaber's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 82
  • Thank you received: 21
  • Karma: 4
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 administrator has disabled public write access.
The following user(s) said Thank You: dmoci

Customize timestamp 9 months 2 weeks ago #100570

  • dmoci
  • dmoci's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
This works perfect, just as I need it. Thanks a lot!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.119 seconds
Donation Image