<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-314  評(píng)論-209  文章-0  trackbacks-0

    在linux下獲取時(shí)間字符串
    命令 date
    # 以yyyymmdd格式輸出23天之前現(xiàn)在這個(gè)時(shí)刻的時(shí)間
    $ date +%Y%m%d –date=’23 days ago’

    $ date -u
    Thu Sep 28 09:32:04 UTC 2006

    $ date -R
    Thu, 28 Sep 2006 17:32:28 +0800

    # 測(cè)試十億分之一秒
    $ date +’%Y%m%d %H:%M:%S.%N’;date +’%Y%m%d %H:%M:%S.%N’;date +’%Y%m%d %H:%M:%S.%N’;date +’%Y%m%d %H:%M:%S.%N’
    20060928 17:44:20.906805000
    20060928 17:44:20.909188000
    20060928 17:44:20.911535000
    20060928 17:44:20.913886000
    date 參考
    $ date –help
    Usage: date [OPTION]… [+FORMAT]
    or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
    Display the current time in the given FORMAT, or set the system date.

    -d, –date=STRING display time described by STRING, not `now’
    # such as ‘n days ago |1 month ago|n years ago’
    -f, –file=DATEFILE like –date once for each line of DATEFILE
    -ITIMESPEC, –iso-8601[=TIMESPEC] output date/time in ISO 8601 format.
    TIMESPEC=`date’ for date only,
    `hours’, `minutes’, or `seconds’ for date and
    time to the indicated precision.
    –iso-8601 without TIMESPEC defaults to `date’.
    -r, –reference=FILE display the last modification time of FILE
    -R, –rfc-2822 output RFC-2822 compliant date string
    -s, –set=STRING set time described by STRING
    -u, –utc, –universal print or set Coordinated Universal Time
    –help display this help and exit
    –version output version information and exit

    FORMAT controls the output. The only valid option for the second form
    specifies Coordinated Universal Time. Interpreted sequences are:

    %% 輸出%符號(hào) a literal %
    %a 當(dāng)前域的星期縮寫 locale’s abbreviated weekday name (Sun..Sat)
    %A 當(dāng)前域的星期全寫 locale’s full weekday name, variable length (Sunday..Saturday)
    %b 當(dāng)前域的月份縮寫 locale’s abbreviated month name (Jan..Dec)
    %B 當(dāng)前域的月份全稱 locale’s full month name, variable length (January..December)
    %c 當(dāng)前域的默認(rèn)時(shí)間格式 locale’s date and time (Sat Nov 04 12:02:33 EST 1989)
    %C n百年 century (year divided by 100 and truncated to an integer) [00-99]
    %d 兩位的天 day of month (01..31)
    %D 短時(shí)間格式 date (mm/dd/yy)
    %e 短格式天 day of month, blank padded ( 1..31)
    %F 文件時(shí)間格式 same as %Y-%m-%d
    %g the 2-digit year corresponding to the %V week number
    %G the 4-digit year corresponding to the %V week number
    %h same as %b
    %H 24小時(shí)制的小時(shí) hour (00..23)
    %I 12小時(shí)制的小時(shí) hour (01..12)
    %j 一年中的第幾天 day of year (001..366)
    %k 短格式24小時(shí)制的小時(shí) hour ( 0..23)
    %l 短格式12小時(shí)制的小時(shí) hour ( 1..12)
    %m 雙位月份 month (01..12)
    %M 雙位分鐘 minute (00..59)
    %n 換行 a newline
    %N 十億分之一秒 nanoseconds (000000000..999999999)
    %p 大寫的當(dāng)前域的上下午指示 locale’s upper case AM or PM indicator (blank in many locales)
    %P 小寫的當(dāng)前域的上下午指示 locale’s lower case am or pm indicator (blank in many locales)
    %r 12小時(shí)制的時(shí)間表示(時(shí):分:秒,雙位) time, 12-hour (hh:mm:ss [AP]M)
    %R 24小時(shí)制的時(shí)間表示 (時(shí):分,雙位)time, 24-hour (hh:mm)
    %s 自基礎(chǔ)時(shí)間 1970-01-01 00:00:00 到當(dāng)前時(shí)刻的秒數(shù) seconds since `00:00:00 1970-01-01 UTC’ (a GNU extension)
    %S 雙位秒 second (00..60); the 60 is necessary to accommodate a leap second
    %t 橫向制表位(tab) a horizontal tab
    %T 24小時(shí)制時(shí)間表示 time, 24-hour (hh:mm:ss)
    %u 數(shù)字表示的星期(從星期一開(kāi)始 1-7)day of week (1..7); 1 represents Monday
    %U 一年中的第幾周星期天為開(kāi)始 week number of year with Sunday as first day of week (00..53)
    %V 一年中的第幾周星期一為開(kāi)始 week number of year with Monday as first day of week (01..53)
    %w 一周中的第幾天 星期天為開(kāi)始 0-6 day of week (0..6); 0 represents Sunday
    %W 一年中的第幾周星期一為開(kāi)始 week number of year with Monday as first day of week (00..53)
    %x 本地日期格式 locale’s date representation (mm/dd/yy)
    %X 本地時(shí)間格式 locale’s time representation (%H:%M:%S)
    %y 兩位的年 last two digits of year (00..99)
    %Y 年 year (1970…)
    %z RFC-2822 標(biāo)準(zhǔn)時(shí)間格式表示的域 RFC-2822 style numeric timezone (-0500) (a nonstandard extension)
    %Z 時(shí)間域 time zone (e.g., EDT), or nothing if no time zone is determinable

    By default, date pads numeric fields with zeroes. GNU date recognizes
    the following modifiers between `%’ and a numeric directive.

    `-’ (hyphen) do not pad the field
    `_’ (underscore) pad the field with spaces

    posted on 2010-04-20 10:55 xzc 閱讀(6959) 評(píng)論(1)  編輯  收藏 所屬分類: linux/unix

    評(píng)論:
    # re: shell:date 常用方式 2010-04-20 10:56 | xzc
    [root@108test ~]# date -d today +"%Y-%m-%d"
    2008-05-07

    [root@108test ~]# date -d today +"%Y_%-m_%-d"
    2008_5_7

    [root@108test ~]# date -d today +"%Y-%m-%d %T"
    2008-05-07 14:55:19

    [root@108test ~]# date -d today +"%Y-%m-%d %H:%M"
    2008-05-07 14:55


    [root@108test ~]# date -d today +"%Y-%m-%d %H:%M:%S"
    2008-05-07 14:55:57  回復(fù)  更多評(píng)論
      
    主站蜘蛛池模板: 国产日产亚洲系列| 久久精品国产96精品亚洲 | 亚洲av永久无码制服河南实里 | 亚洲中文字幕久久精品无码APP| 久久精品国产亚洲沈樵| 91精品成人免费国产片| 久久久久久亚洲精品中文字幕| 亚洲AV无码精品无码麻豆| 亚洲国产精品成人综合久久久 | 亚洲精品乱码久久久久久| 亚洲一区二区三区首页| 亚洲午夜无码毛片av久久京东热| 高潮内射免费看片| 日本免费中文字幕| 国内一级一级毛片a免费| 亚洲一区视频在线播放| 亚洲精品国产福利在线观看| 日韩国产欧美亚洲v片| 日本一区午夜艳熟免费| 成年男女男精品免费视频网站| 亚洲一区二区三区在线视频| 亚洲精品在线电影| 欧洲精品码一区二区三区免费看| 免费成人高清在线视频| 日本最新免费不卡二区在线| 久久精品九九亚洲精品天堂| 亚洲色大18成人网站WWW在线播放| 久久国产精品免费| 免费电视剧在线观看| 丁香五月亚洲综合深深爱| 国产精品亚洲四区在线观看| 中文永久免费观看网站| 女人18毛片免费观看| 久久久久无码精品亚洲日韩| 国产偷国产偷亚洲高清在线 | 国产亚洲AV夜间福利香蕉149| 成人超污免费网站在线看| 国产亚洲AV夜间福利香蕉149| 精品亚洲国产成人| a视频在线免费观看| 国产精品国产自线拍免费软件|