as.POSIXct() support RFC 3339 date- and timestamps without the 'T' specification ('YYYY-MM-DD hh:mm:ss');
> as.POSIXct("2025-06-28 08:53:33")
[1] "2025-06-28 08:53:33 CEST"
but not ISO 8601 date- and timestamps ('YYYY-MM-DDThh:mm:ss'):
> as.POSIXct("2025-06-28T08:53:33")
[1] "2025-06-28 CEST"
which silently drops the time component.
To parse the latter, we need to explicitly use strptime();
as.POSIXct(strptime("2025-06-28T08:53:33", "%Y-%m-%dT%H:%M:%S"))
[1] "2025-06-28 08:53:33 CEST"
From [1]: "Separating date and time parts with other characters such as space is not allowed in ISO 8601, but allowed in its profile RFC 3339."
Wish
- Make
as.POSIXct() recognize also ISO 8601 date- and timestamps.
References
[1] Section 'Combined date and time representations' in Wikipedia article 'ISO-8601', 2025-06-28 https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
as.POSIXct()support RFC 3339 date- and timestamps without the 'T' specification ('YYYY-MM-DD hh:mm:ss');but not ISO 8601 date- and timestamps ('YYYY-MM-DDThh:mm:ss'):
which silently drops the time component.
To parse the latter, we need to explicitly use
strptime();From [1]: "Separating date and time parts with other characters such as space is not allowed in ISO 8601, but allowed in its profile RFC 3339."
Wish
as.POSIXct()recognize also ISO 8601 date- and timestamps.References
[1] Section 'Combined date and time representations' in Wikipedia article 'ISO-8601', 2025-06-28 https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations