Converting character in date/time format (POSIXct) works on Windows not Linux
NickName:Richard Kolodziej Ask DateTime:2013-11-24T22:23:43

Converting character in date/time format (POSIXct) works on Windows not Linux

I can't figure out why the following line of R script works perfectly fine on Windows (7, 64bit with R 3.0.2 64bit) but not on Linux (3.12.1-1-ARCH GNU/Linux 64bit with R 3.0.2 64bit):

Windows:

>strptime("2013-05-08 10:27:50", format="%Y-%m-%d %H:%M:%S")
>[1] "2013-05-08 10:27:50"

Linux:

> strptime("2013-05-08 10:27:50", format="%Y-%m-%d %H:%M:%S")
>NA

There is some reference to "LC_TIME locale category" in the description of strptime but I really don't know if this is relevant to my problem.

Could somebody please explain, why the same line of code leads to different results and how I can make the Linux version of R behave the way of the Windows version?

Copyright Notice:Content Author:「Richard Kolodziej」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/20175641/converting-character-in-date-time-format-posixct-works-on-windows-not-linux

More about “Converting character in date/time format (POSIXct) works on Windows not Linux” related questions

Converting character in date/time format (POSIXct) works on Windows not Linux

I can't figure out why the following line of R script works perfectly fine on Windows (7, 64bit with R 3.0.2 64bit) but not on Linux (3.12.1-1-ARCH GNU/Linux 64bit with R 3.0.2 64bit): Windows: >

Show Detail

R - converting date and time fields to POSIXct with HHMMSS format

I have a data file which has three columns thus: 20010101 000000 0.833 20010101 000500 0.814 20010101 001000 0.794 20010101 001500 0.772 ... As is fairly clear to human eyes, the first two ar...

Show Detail

why converting time zone not working with as.POSIXct... [R]

I've read this and it says as.POSIXct is always UTC internally. No wonder I got > time1 = as.POSIXct('2015-10-25 10:15:13 UTC') > time1 [1] "2015-10-25 10:15:13 EDT" # missing tz causes coe...

Show Detail

Converting datetime from character to POSIXct object

I have an instrument that exports data in an unruly time format. I need to combine the date and time vectors into a new datetime vector in the following POSIXct format: %Y-%m-%d %H:%M:%S. Out of

Show Detail

Converting a character to a Date Time format in R

Don't know what I'm doing wrong here. Am trying to convert a character to a POSIXct date format and getting a null. Here is some sample code: as.POSIXct(strptime("29-MAR-2015 01:14:32", format = "...

Show Detail

Converting factor date time columns into POSIXct in R

I have another problem. I have a date time column in a data frame, which when i upload it comes as factor and I want it to be POSIXct str(ida$DATA_TRAMA) Factor w/ 1122932 levels "1-1-2010 00:00:...

Show Detail

converting datetime string to POSIXct date/time format in R

Consider a string in the format test <- "YYYY-MM-DDT00:00:00.000-08:00" My goal is to convert those strings to POSIXct format so that I can plot the data. my initial thought was to use as.PO...

Show Detail

NA for 1 particular date when converting dates from "character" format to "POSIXct" with as.POSIXct

I'm converting a string vector to date format with as.POSIXct(). Here is the strange thing: as.POSIXct("2017-03-26 03:00:00.000",format="%Y-%m-%d %H") #Gives "2017-03-26 03:00:00 CEST"

Show Detail

NA result in converting string to POSIXct date time in R

Uploading csv file and converting a datetime from character to POSIXct I stumbled in a unexpected NA result: as.POSIXct("20210328 02:00:00", format = "%Y%m%d %H:%M:%S") this see...

Show Detail

How to preserve decimal values when converting POSIXct to character?

> t <- Sys.time() > ct <- as.character(t) > t - as.POSIXct(ct) Time difference of 0.4370408 secs The above example indicates that precision is lost when converting POSIXct to charac...

Show Detail