HTML动态显示当前时间段
效果如下
shell方式
定义时间范围变量,修改html文件添加变量,重定向即可
#定义起始时间变量
START_TIME=$(date +"%Y年%m月%d日")
END_TIME=$(date +"%Y年%m月%d日" -d '+1days')
echo $END_TIME $START_TIME
#定义HTML变量
<div class="content-right-head">系统维护升级中</div>
<div class="content-right-prompt">暂无法使用,为您带来的不便,敬请谅解</div>
<div class="content-right-time">维护时间:${START_TIME} 20:00 -- ${END_TIME} 06:00</div>
#读取变量+重定向输出
cat > 1.temp <<EOF
<!DOCTYPE html>
...
</html>
EOF
#覆盖原有文件
\cp /usr/local/nginx/html/1.temp /usr/local/nginx/html/index.html