I am trying to recheck is the code component whether it is working or not,
thus I try to recall the variable of timeQuestionStart to be displayed on the answerScreen routine by recalling that variable with ‘$’
Here is the picture of the code I am trying to make
timeQuestionStart = time.strftime (core.MonotonicClock.getTime());
anyway, I have import time
at the beginning of the experiment
Here is the picture of the error Message

I am using PsychoPy3 2020.1.3 in Win10
You have timeQuestionsStart at the Beginning or a Routine not Begin Experiment. Either move the code to Begin Experiment or change the text to “set every repeat”.

Thank you so much for your kind and fast response. I have moved it to the Begin Experiment Tab. However, I have got the error messages above. Do you have any idea how can I solve this?
@syifahah, getTime is a method of the core.MonotonicClock class, and to use it you need to create an instance of the clock class (see code below). However, the MonotonicClock class is probably not what you want, because you cannot reset the MonotonicClock, e.g., at the start of each trial, instead MonotonicClock gives you the time since the clock was created. If you want a clock you can reset at any point, try
myClock = core.Clock() # create instance of Clock class
myClock.reset() # reset to zero
myClock.getTime()
If you really do want MonotonicClock, then use myClock = core.MonotonicClock()
, but make no calls to reset
. Are you using time.strftime
for any reason other than to format the time as a string? If you are creating a counter to show how long the participant is taking to answer the question, you can use the following to get the time in seconds as a string, formatted to 2 decimal places.
timeQuestionStart = "{:.2f}".format(myClock.getTime())
1 Like