免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2111 | 回复: 5

[日期时间] SUSE用date 处理日期是不是有个BUG [复制链接]

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-04-19 06:20:00
发表于 2015-11-26 11:18 |显示全部楼层
date -d "20150731 1 month ago " +%Y%m%d 就是取指定20150731的上一个月
结果竟然是20150701
同样的还有20151031
其他天都是正常的,有人碰到这样问题?

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
发表于 2015-11-26 13:03 |显示全部楼层
info date
里面有讲解

论坛徽章:
5
金牛座
日期:2015-07-03 13:32:00卯兔
日期:2015-07-03 13:32:17程序设计版块每日发帖之星
日期:2015-11-29 06:20:0015-16赛季CBA联赛之同曦
日期:2015-12-15 09:36:06CU十四周年纪念徽章
日期:2016-07-06 17:18:48
发表于 2015-11-26 13:22 |显示全部楼层
回复 2# waker

你好,我在info date里面看到:
`-d DATESTR'
`--date=DATESTR'
     Display the date and time specified in DATESTR instead of the
     current date and time.  DATESTR can be in almost any common
     format.  It can contain month names, time zones, `am' and `pm',
     `yesterday', etc.  For example, `--date="2004-02-27
     14:19:13.489392193 +0530"' specifies the instant of time that is
     489,392,193 nanoseconds after February 27, 2004 at 2:19:13 PM in a
     time zone that is 5 hours and 30 minutes east of UTC.  *Note Date
     input formats::.

怎么去看最后一句“*Note Date input formats",是还有一个节点吗?怎么跳转过去,或者在info里面指定这个节点去看?

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
发表于 2015-11-26 13:25 |显示全部楼层
回复 3# seanking1987


    光标移到带*的句子上回车

论坛徽章:
5
金牛座
日期:2015-07-03 13:32:00卯兔
日期:2015-07-03 13:32:17程序设计版块每日发帖之星
日期:2015-11-29 06:20:0015-16赛季CBA联赛之同曦
日期:2015-12-15 09:36:06CU十四周年纪念徽章
日期:2016-07-06 17:18:48
发表于 2015-11-26 13:33 |显示全部楼层
回复 4# waker


非常感谢,以前只看看man,觉得info麻烦,但是麻烦才能学到内在的东西。
info果然详细,顺便解答一些楼主@xby_cn:
The fuzz in units can cause problems with relative items.  For
example, `2003-07-31 -1 month' might evaluate to 2003-07-01, because
2003-06-31 is an invalid date.  To determine the previous month more
reliably, you can ask for the month before the 15th of the current
month.  For example:

     $ date -R
     Thu, 31 Jul 2003 13:02:39 -0700
     $ date --date='-1 month' +'Last month was %B?'
     Last month was July?
     $ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!'
     Last month was June!

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2016-04-19 06:20:00
发表于 2015-11-26 15:03 |显示全部楼层
感谢各位大神,让我收益匪浅
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP