Thank you for your reply. I discovered the OlsonNames() function to get the time-zone names in my system. Rui get a warning message when using a not recognized tz. On my system this doesn't succed.
I solved as follow: dt1 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = "Europe/Rome") dt2 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = "America/Los_Angeles") dt1[1] "2014-04-18 09:00:00 CEST"dt2[1] "2014-04-18 09:00:00 PDT"dt1-dt2Time difference of -9 hours Thank you, Nicola 2014-04-18 21:59 GMT+02:00 Prof Brian Ripley <rip...@stats.ox.ac.uk>: > On 18/04/2014 19:46, Rui Barradas wrote: > >> Hello, >> >> The reason why is that you've misspelled CET (not CEST) >> > > Neither CET nor CEST are portable time-zone names. We have not been given > the 'at a minimum' information required by the posting guide, so please > read ?Sys.timezone on your system. > > > > >> > dt1 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = >> "CEST") >> Warning messages: >> 1: In strptime(x, format, tz = tz) : unknown timezone 'CEST' >> 2: In as.POSIXct.POSIXlt(as.POSIXlt(x, tz, ...), tz, ...) : >> unknown timezone 'CEST' >> > dt2 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = >> "GMT") >> > dt1 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = >> "CET") >> > dt1-dt2 >> Time difference of -2 hours >> >> >> Hope this helps, >> >> Rui Barradas >> >> Em 18-04-2014 17:13, Nicola Sturaro Sommacal escreveu: >> >>> Hi. >>> >>> I am new to POSIX and I'd like to understand the reason of this >>> difference. >>> >>> dt1 = as.POSIXct("2014-03-29 09.00", format="%Y-%m-%d %H.%M") >>> dt2 = as.POSIXct("2014-03-30 09.00", format="%Y-%m-%d %H.%M") >>> dt2-dt1 >>> >>> dt1[1] "2014-03-29 09:00:00 CET"> dt2[1] "2014-03-30 09:00:00 CEST"> >>>> dt2-dt1 >>>> >>> >>> Time difference of 23 hours >>> >>> This is right, because on Mar 31 at 2 PM we jump directly to 3PM, DST. >>> >>> On the contrary, I don't understand the following: >>> >>> dt1 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = >>> "CEST") >>> dt2 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = >>> "GMT") >>> >>> dt1[1] "2014-04-18 09:00:00 CEST"> dt2[1] "2014-04-18 09:00:00 GMT"> >>>> dt1-dt2Time difference of 0 secs >>>> >>> >>> >>> I should expected a time difference of 2 hours, as CEST is GMT+2. >>> >>> Anyone can help me? >>> >>> Thank you, >>> Nicola >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list >>> 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. >>> >>> >> ______________________________________________ >> R-help@r-project.org mailing list >> 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. >> > > > -- > Brian D. Ripley, rip...@stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 272595 > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list 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.