Created
September 8, 2013 08:14
-
-
Save phx/6482865 to your computer and use it in GitHub Desktop.
Get Apple Epoch Time from Unix Epoch Time
This file contains 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
#/bin/bash | |
# 1) create function to get current Unix Epoch Time | |
EPOCHTIME () { date -u +%s; } | |
# $ EPOCHTIME | |
# 1378623423 | |
# $ EPOCHTIME | |
# 1378623429 | |
# 2) get Unix Epoch Time at 12am on January 1, 2001, as STATIC variable | |
APPLETIME="$(date -d 20010101 -u +%s)" | |
# $ echo $APPLETIME | |
# 978307200 | |
# 3) create the function to obtain current Apple Epoch Time | |
APPLEPOCH () { echo "$(($(EPOCHTIME)-$(APPLETIME)))"; } | |
# $ APPLEPOCH | |
# 400349476 | |
# $ APPLEPOCH | |
# 400349478 | |
# now Apple Epoch Time can be referenced by a DYNAMIC variable like this: | |
# $ echo $(APPLEPOCH) | |
# 400349922 | |
# $ echo $(APPLEPOCH) | |
# 400349926 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment