| Reference | Downloads | Github

Get total experiment time for the online version

I added psychoJS.experiment.addData(“globalClockTime”, globalClock.getTime())
in end experiment in order to get total experiment time, but it doesn’t seem to work. It seems that I don’t get a globalClockTime column in the output datafile. What should i do? Thanks!!

@CatK, currently the code will not be written in the “End JS Experiment” tab (fix pending) but in the mean time, if you add the following to the “End JS Routine” tab of your final routine in your task, you will get the final time of the experiment at the end of the final routine, which will be equivalent to having it at the end of the experiment:

psychoJS.experiment.addData(“globalClockTime”, globalClock.getTime());
1 Like

Hello @dvbridges,

I am creating a routine at the end of my experiment and create a code component.
Then, I putting the following code as you suggested;

psychoJS.experiment.addData(“globalClockTime”, globalClock.getTime());

However, the experiment does not run on Pavlovia. It stuck at “initializing the experiment” page. And when I try o debug by F12, I get “Uncaught SyntaxError: Invalid or unexpected token” and it highlights the code that I entered for globalClockTime.

Do you know if any changes are made regarding GlobalClock time?

Many Thanks!!

Hi @emregurbuz, the code seems ok, so perhaps something went wrong with the formatting if you used copy and paste. Try manually replacing in the " quotation marks with single or double quote marks using the keyboard. If that does not work, it may be that there is some other code causing the error.

Hi @dvbridges!

Sorry for late response. And indeed the code was perfect but the quotation mark was problematic. I don’t know how I did not see this.

Many thanks!