# Log timestamp in Unix time

**URL:** <https://discourse.psychopy.org/t/log-timestamp-in-unix-time/27005>\
**Category:** Builder\
**Tags:** logfiles, timing\
**Created:** [January 25, 2022, 8:51am UTC](https://discourse.psychopy.org/t/log-timestamp-in-unix-time/27005 "2022-01-25T08:51:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![federico\_nemmi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/federico_nemmi/32/32478_2.png) [@federico\_nemmi](https://discourse.psychopy.org/u/federico_nemmi)\
**Post date:** [January 25, 2022, 8:51am UTC](https://discourse.psychopy.org/t/log-timestamp-in-unix-time/27005/1 "2022-01-25T08:51:12Z")

</div>

If this template helps then use it. If not then just delete and start from scratch.

**OS** : Windows 10  
**PsychoPy version** : 2021.2.3  
**Standard Standalone?** Yes  
**What are you trying to achieve?:**  
I would like to log the time of onset and offset of my stimuli and the subjects response in Unix time instead than time elapsed. I have to match my stimuli with data coming from a VR headset (off-line) for whom I have timestamp in Unix time.  
Actually, I do not care much about extreme precision of timing, since I have just to roughly get a time window (in the order of the tens of seconds).

**What did you try to make it work?:**  
I guess not much, I have tried to have a look to actually code the whole experiment, but I have to confess that what was appealing in psychopy was that such a simple experiment like mine would be extremely easy to setup (I literally just need to show some instructions and then 5 images for 10 seconds each and register one keypress). If I have to code from scratch it becomes suddenly less appealing.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [January 25, 2022, 4:48pm UTC](https://discourse.psychopy.org/t/log-timestamp-in-unix-time/27005/2 "2022-01-25T16:48:13Z")

</div>

This might help

> [@Is it possible to record UNIX time with millisecond precision?](https://discourse.psychopy.org/t/is-it-possible-to-record-unix-time-with-millisecond-precision/9843/2):
>
> Hi @nrh31, have you thought about using Pythons time package? [See docs](https://docs.python.org/3/library/time.html#time.time). You could save time at specific events using: # Begin Experiment import time # Each Frame if event == true: thisExp.addData("utcTime", time.time()) Note, the time docs do say that not all systems provide time with better precision that 1 second.

---

<div class="post-metadata">

**Author:** ![federico\_nemmi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/federico_nemmi/32/32478_2.png) [@federico\_nemmi](https://discourse.psychopy.org/u/federico_nemmi)\
**Post date:** [January 26, 2022, 9:19am UTC](https://discourse.psychopy.org/t/log-timestamp-in-unix-time/27005/3 "2022-01-26T09:19:42Z")

</div>

@wakecarter, thanks for your answer. Indeed it is the type of solution that I have adopted. I just thought that there was a way of doing it automatically from the builder that I was missing somehow.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [January 26, 2022, 10:01am UTC](https://discourse.psychopy.org/t/log-timestamp-in-unix-time/27005/4 "2022-01-26T10:01:45Z")

</div>

Lots of things in Builder require the addition of code components. Use Builder to create the structure of your experiments and the code components to go beyond the capabilities of the standard components.
