How can I change the format of a date from the command line?

后端 未结 6 1553
梦毁少年i
梦毁少年i 2020-12-19 17:04

What\'s the quickest way to convert a date in one format, say

2008-06-01

to a date in another format, say

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 17:53

    date -d ... 
    

    doesn't seem to cut it, as I get a usage error:

    usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
                [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
    

    I'm running GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0), and as far as the man goes, date -d is just for

    -d dst  Set the kernel's value for daylight saving time.  If dst is non-
             zero, future calls to gettimeofday(2) will return a non-zero for
             tz_dsttime.
    

提交回复
热议问题