Skip to content

Instantly share code, notes, and snippets.

@jpalala
Created June 29, 2024 00:18
Show Gist options
  • Save jpalala/111fc01f5be392f2d0ec87f1460331d9 to your computer and use it in GitHub Desktop.
Save jpalala/111fc01f5be392f2d0ec87f1460331d9 to your computer and use it in GitHub Desktop.
clock monotonic time
<?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();
@jpalala
Copy link
Author

jpalala commented Jun 29, 2024

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