How to convert YYYYMMDDHHMMSS to a date readable by `date`

前端 未结 6 369
执笔经年
执笔经年 2020-12-07 04:21

I have a set of date/time strings in the YYYYMMDDHHMMSS format that I want to convert to something readable by the date utility. Usually, I can do something li

6条回答
  •  [愿得一人]
    2020-12-07 04:49

    Either busybox date or bsd date accept a description of the input format.

    Busybox is a GNU small utility, easy to install.

    The bsd format has been covered in another answer, so here is busybox:

    $ busybox date -D "%Y%m%d%H%M%S" -d "20100101123456" +'%Y-%m-%d %H:%M:%S'
    2010-01-01 12:34:56
    

提交回复
热议问题