The "lubridate" package will help simplify these time zone conversions. It
provides two simple functions with_tz and force_tz that conceptually make
things simpler.
library(lubridate)
> x <- as.POSIXct("2015-06-22 01:53:28", 'Europe/Berlin')
> with_tz(x, 'America/Toronto')
[1] "2015-06-21 19:53:28 EDT"
HTH,
J
-----Original Message-----
From: R-help [mailto:[email protected]] On Behalf Of Ronny Steen
Sent: Sunday, November 22, 2015 2:52 AM
To: [email protected]
Subject: [R] Converting time zones in R using metadata file information of
video files, help needed.
Hi,
I have video files (FAT) that are taken in a different timezone than my current
location. The modification date/time in the metafila data of the video file
shows the time video was taken, although in the current timezone of my
computer, if I understand right.
I wish to convert the date/time to the origin. The video was taken in London,
Ontario Canada at 2015-06-21 07:53:28, when looking at the metadata of the file
on my computer (timezone "Europe/Berlin") it says modification date "2015-06-22
01:53:28". Hence, there is a 6 hour difference between the two time-zones
I use the script provided here:
http://blog.revolutionanalytics.com/2009/06/converting-time-zones.html
pb.txt <- "2015-06-22 01:53:28" #modification date as shown on my computer
(timezone
"Europe/Berlin")
pb.date <- as.POSIXct(pb.txt, tz="Europe/London")
pb.date <- as.POSIXct(pb.txt, tz="America/Toronto")#timezone of origin video
camera location
format(pb.date, tz=local.time,usetz=TRUE) #formats the mtime to data and time
when the video was taken
[1] "2015-06-22 07:53:28 CEST" # the time is correct but the date is wrong as
it has added 6 hours rather than subtracting.
I find working with different time-zones to be difficult, I hope I managed to
formulate an understandable question.
Regards,
Kes
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.