Linux时间函数的应用


由于Linux对man date -d 参数说的比较模糊,故举例如下:

# -d, --date=STRING display time described by STRING, not `now'

For Linux
[root@Gman root]# date -d next-day +%Y%m%d
20060328
[root@Gman root]# date -d last-day +%Y%m%d
20060326
[root@Gman root]# date -d yesterday +%Y%m%d
20060326
[root@Gman root]# date -d tomorrow +%Y%m%d
20060328
[root@Gman root]# date -d last-month +%Y%m
200602
[root@Gman root]# date -d next-month +%Y%m
200604
[root@Gman root]# date -d next-year +%Y
2007 

相关内容