# Get total experiment time for the online version

**URL:** <https://discourse.psychopy.org/t/get-total-experiment-time-for-the-online-version/10027>\
**Category:** Online experiments\
**Created:** [November 25, 2019, 4:27am UTC](https://discourse.psychopy.org/t/get-total-experiment-time-for-the-online-version/10027 "2019-11-25T04:27:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CatK](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/catk/32/6087_2.png) [@CatK](https://discourse.psychopy.org/u/CatK)\
**Post date:** [November 25, 2019, 4:27am UTC](https://discourse.psychopy.org/t/get-total-experiment-time-for-the-online-version/10027/1 "2019-11-25T04:27:21Z")

</div>

I added psychoJS.experiment.addData(“globalClockTime”, globalClock.getTime())  
thisExp.nextEntry()  
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!!

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [November 25, 2019, 10:58am UTC](https://discourse.psychopy.org/t/get-total-experiment-time-for-the-online-version/10027/2 "2019-11-25T10:58:44Z")

</div>

@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:

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

```

---

<div class="post-metadata">

**Author:** ![emregurbuz](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@emregurbuz](https://discourse.psychopy.org/u/emregurbuz)\
**Post date:** [July 9, 2020, 6:54am UTC](https://discourse.psychopy.org/t/get-total-experiment-time-for-the-online-version/10027/3 "2020-07-09T06:54:15Z")

</div>

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;

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

```

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!!

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [July 9, 2020, 2:56pm UTC](https://discourse.psychopy.org/t/get-total-experiment-time-for-the-online-version/10027/4 "2020-07-09T14:56:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![emregurbuz](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@emregurbuz](https://discourse.psychopy.org/u/emregurbuz)\
**Post date:** [July 15, 2020, 4:25pm UTC](https://discourse.psychopy.org/t/get-total-experiment-time-for-the-online-version/10027/5 "2020-07-15T16:25:23Z")

</div>

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!
