Jeppe Olsen
Jeppe Olsen

Reputation: 1008

Weird as.POSIXct behavior depending on daylight savings time

It seems there is a bug in as.POSIXct. Or what is going on?

as.POSIXct("27/03/2006 02:05:38", format="%d/%m/%Y %H:%M:%S") 
[1] "2006-03-27 02:05:38 CEST"

as.POSIXct("26/03/2006 02:05:38", format="%d/%m/%Y %H:%M:%S")
[1] NA

March 26, 2006 happened as far as I know...

Upvotes: 1

Views: 282

Answers (1)

Shique
Shique

Reputation: 744

if you really want it printed with the times you can always do.

as.POSIXct("26/03/2006 02:05:38", format="%d/%m/%Y %H:%M:%S", tz = "UTC")
#[1] "2006-03-26 02:05:38 UTC"

Just make sure you do this for all conversions for consistency.

As Wikipedia states:

UTC does not change with a change of seasons, but local time or civil time may change if a time zone jurisdiction observes daylight saving time (summer time). For example, local time on the east coast of the United States is five hours behind UTC during winter, but four hours behind while daylight saving is observed there.

Upvotes: 1

Related Questions