| Reference | Downloads | Github

Record onset/offset times in online experiments / PsychJS

Hi everyone,

simple question, but I could not get a definitive answer yet:

How can I save onset/offset times in online experiments?

It’s not done automatically (like in the Builder), right?

Any way to do it with code components?


hi, i had the same issue a few weeks ago. See the thread below. Using the code component worked perfectly.

Hi @Stuart_Furnell,

thanks for the response!

I implemented your solution but the values that were saved were all quite small (e.g., 0.0001) so I suspect that the tStart refers to the onset of the corresponding Component since the onset of the Routine. This would make sense, since all Components of all my Routines start with the onset of the respective Routine.

However, I wanted to save a single onset time for each Routine (sorry, that was not very clear in my original question). I now achieved that by using your code but replacing stimulus.tStart with globalClock.getTime() to get the global time at each Routine onset. By saving the onset time of each Routine I can later figure out the approximate duration of each Routine, which is what I needed.

So thanks again @Stuart_Furnell for the valuable hint! Cheers!

1 Like