# On macOS, GetSecs no longer returns absolute time!

**URL:** <https://psychtoolbox.discourse.group/t/on-macos-getsecs-no-longer-returns-absolute-time/3166>\
**Category:** Bugs & Features\
**Tags:** macos\
**Created:** [April 4, 2020, 5:49pm UTC](https://psychtoolbox.discourse.group/t/on-macos-getsecs-no-longer-returns-absolute-time/3166 "2020-04-04T17:49:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![denis.pelli](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/denis.pelli/32/7_2.png) [@denis.pelli](https://psychtoolbox.discourse.group/u/denis.pelli)\
**Post date:** [April 4, 2020, 5:49pm UTC](https://psychtoolbox.discourse.group/t/on-macos-getsecs-no-longer-returns-absolute-time/3166/1 "2020-04-04T17:49:54Z")

</div>

Under macOS, GetSecs used to return absolute time, mach\_absolutetime() which is seconds since some date like January 1, 1904. This was useful for aligning data collected on multiple computers. I just ran GetSecs on the latest Psychtoolbox under macOS and am very surprised to get a time corresponding to about 40 hours, very likely the time that my computer was last booted. This is a serious reduction of functionality. Can we go back to absolute time, mach\_absolutetime(), as the documentation still says?  
Best  
Denis  
p.s. I wrote the original version of GetSecs in the 1980s.

---

<div class="post-metadata">

**Author:** ![dcnieho](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dcnieho](https://psychtoolbox.discourse.group/u/dcnieho)\
**Post date:** [April 4, 2020, 7:33pm UTC](https://psychtoolbox.discourse.group/t/on-macos-getsecs-no-longer-returns-absolute-time/3166/2 "2020-04-04T19:33:45Z")

</div>

See if `GetSecs('AllClocks')` provides what you need

---

<div class="post-metadata">

**Author:** ![xiangrui](https://avatars.discourse-cdn.com/v4/letter/x/ec9cab/32.png) [@xiangrui](https://psychtoolbox.discourse.group/u/xiangrui)\
**Post date:** [April 4, 2020, 7:44pm UTC](https://psychtoolbox.discourse.group/t/on-macos-getsecs-no-longer-returns-absolute-time/3166/3 "2020-04-04T19:44:02Z")

</div>

This behavior has been a while. I guess it is due to the change in mach\_absolute\_time() by Apple? If so, we will need to update the documentation.

Unfortunately it breaks when you try to align time from multiple computers. But in my opinion, this is a good change in terms of precision. If GetSecs=0 means Jan 1, 1904, its precision for now is at the order of 10e-7 (still enough for most of our purpose, but barely). While GetSecs is about 40 hours, the precision is at the order of 10e-11.  
Best,  
-Xiangrui

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [April 7, 2020, 12:08am UTC](https://psychtoolbox.discourse.group/t/on-macos-getsecs-no-longer-returns-absolute-time/3166/4 "2020-04-07T00:08:00Z")

</div>

GetSecs() never returned absolute time on OSX with PTB-3. mach\_absolute\_time() never did either. Just as GetSecs(), the zero point of mach\_absolute\_time() is unspecified according to docs. In practice it seems to be time since system boot, but this is not to be relied on, just as the help of GetSecs clearly states. Atm. only GetSecs on Linux returns time since 1.1.1973 iirc, but that is only for historical reasons, and at some point, if i ever find the time for it, i may change that to time since boot / CLOCK\_MONOTONIC, because as Xiangrui notes, it provides better absolute precision for various reasons. Also because most system times related to input and output operate in a time-base related to bootup.

We have GetSecs(‘AllClocks’) for purpose of syncing/mapping time across machines/against something like UTC.
