date command on Mac OS

前端 未结 1 1181
余生分开走
余生分开走 2020-12-10 06:54

I would like to use the date command on a Mac to find out the day corresponding to a certain date.

On Debian the command below works:

date --date \"         


        
相关标签:
1条回答
  • 2020-12-10 07:03

    This works:

    date -j -vJulm -v20d -v1999y '+%A'
    

    According to the OSX date manual page::

    -v
    Adjust (i.e., take the current date and display the result of the adjustment; not actually set the date) the second, minute, hour, month day, week day, month or year according to val. If val is preceded with a plus or minus sign, the date is adjusted forwards or backwards according to the remaining string, otherwise the relevant part of the date is set. The date can be adjusted as many times as required using these flags.

    0 讨论(0)
提交回复
热议问题