Linux 版本的 date 解決了這個困擾。
1. 取得今天的日期時間
date '+%Y%m%d%H%M%S'
2. 取得昨天的日期時間
date -d'-1 day' 或 date -d'1 day ago'
3. 取得明天的日期
date -d'1 day'
4. 取得上個月的日期
date -d'-1 month'
5. 取得上星期的日期
date -d'-1 week'
閱讀全文...
Happy coding.
The secret to creativity is knowing how to hide your sources.— Albert Einstein
Good artists copy, great artists steal. – Pablo Picasso
date '+%Y%m%d%H%M%S'
date -d'-1 day' 或 date -d'1 day ago'
date -d'1 day'
date -d'-1 month'
date -d'-1 week'
#!/bin/bash printf "\E[0;35;40m" echo " Menu of available command:" printf "\E[0m" echo " ========================================================" printf "\E[0;31;40m" echo " 1. Check Server Status" echo " 2. display the month 3. display the day" printf "\E[0m" echo " --------------------------------------------------------" printf "\E[0;32;40m" echo " 4. Query Logs" printf "\E[0m" echo " --------------------------------------------------------" printf "\E[0;33;40m" echo " q. quit" printf "\E[0m" echo " ========================================================" printf "\E[0;36;40m" echo -n " Select a number from the list: " printf "\E[0m"