Skip to content

Instantly share code, notes, and snippets.

@janeshdev
Created June 14, 2013 21:47
Show Gist options
  • Save janeshdev/5785563 to your computer and use it in GitHub Desktop.
Save janeshdev/5785563 to your computer and use it in GitHub Desktop.
## Let us assign a sample date as first with hours, minutes and seconds.
## It is also recommended to use the time zone
> date <- as.POSIXct("2013-06-14 16:34:26",tz="GMT")
## Convert to Julian date using the following function
> jddd <- julian(date, origin = as.POSIXct("2013-01-01 00:00:00",tz="GMT"))
> jddd
Time difference of 164.6906 days
## Check the class of object jddd
> class(jddd)
[1] "difftime"
> converted <- as.POSIXct("2013-01-01 00:00:00",tz="GMT")+jddd
> converted
[1] "2013-06-14 16:34:26 GMT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment