#!/bin/bash
#提取时间
#当前时间
clear
echo -e "\e[1;32m时间参数:\e[0m"
echo "====================================="
echo -e "\e[2;31m当前时间:\e[0m"
echo -e "\e[1;32m`date`\e[0m"
echo -e " \e[2;32mdate +%F | `date +%F`\e[0m"
echo -e " \e[2;32mdate +%T | `date +%T`\e[0m"
echo -e " \e[2;32mdate +%c | `date +%c`\e[0m"
echo -e " \e[2;32mdate +%x | `date +%x`\e[0m"
echo -e " \e[2;32mdate +%X | `date +%X`\e[0m"
echo -e " \e[2;32mdate +%r | `date +%r`\e[0m"
echo "====================================="
#年
#date0=`date +%y`
#date1=`date +%Y`
#date2=`date +%w`
echo -e "\e[1;32m 年\e[0m"
echo "+-----------+-----------+"
echo " date +%y | `date +%y`"
echo " date +%Y | `date +%Y`"
echo " date +%w | `date +%w`"
echo "+-----------+-----------+"
#月
#date3=`date +%b`
#date4=`date +%B`
#date5=`date +%m`
echo -e "\e[1;32m 月\e[0m"
echo "+-----------+-----------+"
echo " date +%b | `date +%b`"
echo " date +%B | `date +%B`"
echo " date +%m | `date +%m`"
echo "+-----------+-----------+"
#日
#date6=`date +%D`
#date7=`date +%d`
echo -e "\e[1;32m 日\e[0m"
echo "+-----------+-----------+"
echo " date +%D | `date +%D`"
echo " date +%d | `date +%d`"
echo "+-----------+-----------+"
#星期
#date8=`date +%a`
#date9=`date +%A`
#date10=`date +%w`
echo -e "\e[1;32m 星期\e[0m"
echo "+-----------+-----------+"
echo " date +%a | `date +%a`"
echo " date +%A | `date +%A`"
echo " date +%w | `date +%w`"
echo "+-----------+-----------+"
#时
#date11=`date +%D`
#date12=`date +%d`
echo -e "\e[1;32m 时\e[0m"
echo "+-----------+-----------+"
echo " date +%I | `date +%I`"
echo " date +%H | `date +%H`"
echo " date +%k | `date +%k`"
echo " date +%l | `date +%l`"
echo "+-----------+-----------+"
#分
#date13=`date +%D`
#date14=`date +%d`
echo -e "\e[1;32m 分\e[0m"
echo "+-----------+-----------+"
echo " date +%M | `date +%M`"
echo "+-----------+-----------+"
#秒
#date15=`date +%s`
#date16=`date +%S`
echo -e "\e[1;32m 秒\e[0m"
echo "+-----------+-----------+"
echo " date +%s | `date +%s`"
echo " date +%S | `date +%S`"
echo "+-----------+-----------+"
#其他组合
echo -e "\e[1;32m 其他组合\e[0m"
echo "+---------------------------+-----------+"
echo -e " date -d \"1 days ago\" +%d | `date -d "1 days ago" +%d`"
echo -e " date -d \"1 min ago\" +%M | `date -d "1 min ago" +%M`"
echo -e " date -d \"1 month ago\" +%m | `date -d "1 month ago" +%M`"
echo "+---------------------------+-----------+"
01-08
06-29
776
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-09
03-20
2724
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-14
7814
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)