linux 脚本怎么写当前时间与$1对比并取差值
#!/bin/bash
获取当前时间戳
now=$(date +%s)
将传入的时间参数转换为时间戳
target=$(date -d "$1" +%s)
计算差值
diff=$((target-now))
echo "距离目标时间还有 $diff 秒"
原文地址: https://www.cveoy.top/t/topic/b1Yw 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
#!/bin/bash
now=$(date +%s)
target=$(date -d "$1" +%s)
diff=$((target-now))
echo "距离目标时间还有 $diff 秒"
原文地址: https://www.cveoy.top/t/topic/b1Yw 著作权归作者所有。请勿转载和采集!