Created
September 19, 2020 11:46
-
-
Save minesweeper106/43522c356ac7701b7f51e72c4fa5905c to your computer and use it in GitHub Desktop.
Conversion of IOS timestamps in R to UNIX epochs and readable dates
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
#Conversion to Unix Epoch | |
IosConvertEpoch <- function(timestamp_vector){ | |
convUNIX <- timestamp_vector/1000000000+978307200 | |
} | |
#Conversion to date | |
IosConvertDate <- function(timestamp_vector){ | |
convUNIX <- timestamp_vector/1000000000+978307200 | |
date <- as.Date(as.POSIXct(convUNIX ,tz = "", origin = "1970-01-01", | |
tryFormats = c( | |
"%Y-%m-%d %H:%M:%OS", | |
"%Y/%m/%d %H:%M:%OS", | |
"%Y-%m-%d %H:%M", | |
"%Y/%m/%d %H:%M", | |
"%Y-%m-%d", | |
"%Y/%m/%d"), | |
optional = FALSE )) | |
} | |
#For testing: | |
#vector of IOS timestamps | |
# vec<-c(551000054000000000, 551004813978757632 ,551004862012363648, 551004894680455680) | |
#function calls | |
# IosConvertEpoch(vec) | |
# IosConvertDate(vec) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment