Linux时间函数的应用

2014-11-24 00:58:10 · 作者: · 浏览: 7

由于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