Working with date-time format, cant handle POSIXct. (Error in as.POSIXlt.numeric(x) : 'origin' must be supplied)


I have a date-time column in my database in a format of "2017-01-02 8:27" as example and column name is EventTime. I want to add 10 minutes to this date-time version.

</>dat$EventTime=as.POSIXct(strptime( dat$EventTime, "%Y-%m-%d %H:%M"), tz = "", origin = '1970-01-01 00:00')

date-time format becomes 2017-01-02 08:27:00 which is ok, however when I try to add 10 minutes


I come across with this error

</>Error in as.POSIXlt.numeric(x) : 'origin' must be supplied

Could you please help me with that issue?


I would use the minute function from the lubridate package as follows.

#> Attaching package: 'lubridate'
#> The following object is masked from 'package:base':
#>     date
x <- ymd_hm("2017-01-02 8:27")
#> [1] "2017-01-02 08:27:00 UTC"

minute(x) <- minute(x) + 10
#> [1] "2017-01-02 08:37:00 UTC"

Created on 2019-08-07 by the reprex package (v0.2.1)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.