问题
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...
回答1:
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.
来源:https://stackoverflow.com/questions/50116692/weird-as-posixct-behavior-depending-on-daylight-savings-time