Mac OS 上的日期命令 [英] date command on Mac OS

查看:53
本文介绍了Mac OS 上的日期命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Mac 上使用 date 命令来找出与某个日期对应的日期.

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

在 Debian 上,以下命令有效:

On Debian the command below works:

date --date "Jul 20 1999" +%A

但是当我使用 Mac 的终端时,相同的命令不起作用.

But the same command does not work when I use Mac's terminal.

有什么替代方法可以在 Mac 上实现上述命令的输出?

What can be an alternative to achieve the output of the above command on a Mac?

推荐答案

这有效:

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

根据 OSX 日期手册页面::

-v
调整(即取当前日期并显示调整结果;未实际设置日期)根据 val 的秒、分、小时、月、日、星期、月或年.如果val 前面有加号或减号,日期根据到剩余的字符串,否则设置日期的相关部分.日期可以是使用这些标志根据需要进行多次调整.

-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.

这篇关于Mac OS 上的日期命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆