shell时间戳与时间相互转换


#!/bin/bash
read -p "时间转化为时间戳请输入1,时间戳转化为时间请输入2:" time0
if [ $time0 -eq 1 ];then
  read -p "请输入你要转化的时间戳:" time1
  date -d @"$time1" "+%F %T" 2> /dev/null
fi
if [ $time0 -eq 2 ];then
  read -p "请输入你要转化的时间(xxxx-xx-xx xx:xx:xx):" time2
  date -d "$time2" +%s 2> /dev/null
fi
exit
if [ $time0 -eq 2 ];then
  echo "输入错误!!!"
  exit 
fi

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM