Formatting a date in R without leading zeros

前端 未结 4 1595
野性不改
野性不改 2020-12-07 00:33

Is there a way to use the format function on a date object, specifically an object of class POSIXlt, POSIXct, or Date, wi

4条回答
  •  感情败类
    2020-12-07 01:11

    I have discovered a workaround by using year, month and day function of lubridate package. With the help of glue::glue, it is easy to do it as following:

    require(lubridate)
    require(glue)
    dt <- "1998-09-02"
    glue("{year(dt)}, {month(dt)}, {day(dt)}")
    # 1998, 9, 2
    

提交回复
热议问题