Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How convert decimal to POSIX time

Tags:

time

r

decimal

I use a function from here to calculate the sunrise and sunset and it returns:

         sunrise           sunset
6.49055593325792 18.2873900837081

I am struggling (trying with strftime, POSIXct or as.Date functions) to convert it to real time, but so far without success.

As always, any suggestion is greatly appreciated.

like image 235
stefano Avatar asked Nov 29 '22 02:11

stefano


1 Answers

@Arun's strategy works, but it might be easier to just do:

x <- c(6.49055593325792, 18.2873900837081)
today<-as.POSIXct('2012-01-23 00:00:00 EST')
today + (3600*x)

# "2012-01-23 06:29:26 EST" "2012-01-23 18:17:14 EST"

That will get you the seconds as well.

like image 71
nograpes Avatar answered Dec 05 '22 23:12

nograpes