Created
June 29, 2024 00:18
-
-
Save jpalala/111fc01f5be392f2d0ec87f1460331d9 to your computer and use it in GitHub Desktop.
clock monotonic time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # idea from https://www.netmeister.org/blog/epoch.html | |
// so Mac apparently set their origin of time using to 2001-01-01 00:00:00 (clock monotonic) which is unix epoch (1971-01-01) aka -30 years ago. | |
# ((31556926) * 30) = (number of seconds per year according to epochconverter) * 30 years = 946707780 | |
# per article, it is -978307200 (2001-01-01 00:00:00) so I wonder what explains the diff?? | |
functions get_monotonic($timestamp) { | |
return time() - strtotime('2001-01-01 00:00:00')); | |
} | |
return get_monotonic(); |
edit: unix itme is apparently 1970 not 1971! I always thought it was 1971 for some reason
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I figured the mystery: strtotime 2001-01-01 00:00:00 apparently resolves to 978307200... which means, PHP got it wrong I pressume. 😉