制作一个终端可执行文件来更改 Mac 上的日期

Making a terminal executable file that changes the date on your Mac

如果我们去 SystemPreferences > date and time,我们可以更改 mac 的日期。你能创建一个终端可执行程序,在我打开它时更改日期吗?

您可以从终端使用以下命令更改 mac 的日期。

date -u {month}{day}{hour}{minute}{year}

用两位数替换括号。要设置,2020 年 10 月 16 日 21:16 将变为以下命令:

date 1016211620

或者您可以创建苹果脚本来执行此操作:

set ntpdPID to do shell script "systemsetup -getusingnetworktime; exit 0" with administrator privileges
if ntpdPID is "Network Time: On" then
    do shell script "systemsetup -setusingnetworktime off" with administrator privileges
    do shell script "systemsetup -setdate '01:24:1984' -settime '03:00:00'" with administrator privileges
else
    do shell script "systemsetup -setusingnetworktime on" with administrator privileges
end if

要创建 apple 脚本,请参阅此 reference