以下是使用 Shell 语言将输入时间转换为 NT 时间戳的示例脚本:

#!/bin/bash

# 获取输入时间的时间戳
read -p '请输入时间(格式:YYYY-MM-DD HH:mm:ss):' input_time
input_timestamp=$(date -d '$input_time' +%s)

# 计算 NT 时间戳
nt_timestamp=$(($input_timestamp * 10000000 + 116444736000000000))

# 输出结果
echo '输入时间的 NT 时间戳为:$nt_timestamp'

使用方法:

  1. 将上述代码保存为一个文件,如 nt_timestamp.sh。
  2. 在终端中进入该文件所在目录。
  3. 运行命令 chmod +x nt_timestamp.sh,授予脚本执行权限。
  4. 运行命令 ./nt_timestamp.sh,按照提示输入时间(格式为 YYYY-MM-DD HH:mm:ss)。
  5. 脚本将输出输入时间的 NT 时间戳。
Shell 脚本:将时间转换为 NT 时间戳

原文地址: https://www.cveoy.top/t/topic/oc07 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录