linux時間格式總結

2022-06-13 23:09:15 字數 2459 閱讀 6721

原文:

%%   a literal %   乙個文字

%a   locale's abbreviated weekday name (e.g., sun)   語言環境的縮寫工作日的名字

%a   locale's full weekday name (e.g., sunday)            語言環境的完整工作日的名字

%b   locale's abbreviated month name (e.g., jan)        語言環境的縮寫月的名字

%b   locale's full month name (e.g., january)                語言環境是完整月的名字

%c   locale's date and time (e.g., thu mar  3 23:05:25 2005)  區域設定的日期和時間

%c   century; like %y, except omit last two digits (e.g., 20)      世紀;像% y,只不過省略最後兩位數

%d   day of month (e.g., 01)            某天

%d   date; same as %m/%d/%y           日期;月日年

%e   day of month, space padded; same as %_d   某天 類似%_d

%f   full date; same as %y-%m-%d         完整日期 ,年月日

%g   last two digits of year of iso week number (see %g)

%g   year of iso week number (see %v); normally useful only with %v

%h   same as %b

%h   hour (00..23)

%i   hour (01..12)

%j   day of year (001..366)

%k   hour, space padded ( 0..23); same as %_h

%l   hour, space padded ( 1..12); same as %_i

%m   month (01..12)

%m   minute (00..59)

%n   a newline

%n   nanoseconds (000000000..999999999)

%p   locale's equivalent of either am or pm; blank if not known

%p   like %p, but lower case

%r   locale's 12-hour clock time (e.g., 11:11:04 pm)

%r   24-hour hour and minute; same as %h:%m

%s   seconds since 1970-01-01 00:00:00 utc

%s   second (00..60)

%t   a tab

%t   time; same as %h:%m:%s

%u   day of week (1..7); 1 is monday

%u   week number of year, with sunday as first day of week (00..53)

%v   iso week number, with monday as first day of week (01..53)

%w   day of week (0..6); 0 is sunday

%w   week number of year, with monday as first day of week (00..53)

%x   locale's date representation (e.g., 12/31/99)

%x   locale's time representation (e.g., 23:13:48)

%y   last two digits of year (00..99)

%y   year

%z   +hhmm numeric time zone (e.g., -0400)

%:z  +hh:mm numeric time zone (e.g., -04:00)

%::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)    + hh:mm:ss數字時區

%:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)  模時區:必要的精度

%z   alphabetic time zone abbreviation (e.g., edt)          字母時區縮寫

哈哈,懶得翻譯了,需要時再翻譯吧,我這邊最常用的就是年月日,時分秒的格式,其他的了解就行。

linux 時間格式

時間域 h 小時 00.23 i 小時 01.12 k 小時 0.23 l 小時 1.12 m 分 00.59 p 顯示出am或pm r 時間 hh mm ss am或pm 12小時 s 從1970年1月1日00 00 00到目前經歷的秒數 s 秒 00.59 t 時間 24小時制 hh mm ss...

時間格式化總結

時間轉換 例 2019 10 10 15 06 00 2019年10月10日 15時06分00秒 function dateformattime time 時間轉換 例 2019 10 10 15 06 00 2019年10月10日 function dateformat time else els...

IOS 時間格式 時間轉換 大總結

例項化乙個nsdateformatter物件 nsdateformatter dateformatter nsdateformatter alloc init 設定時間格式,這裡可以設定成自己需要的格式 dateformatter setdateformat yyyy mm dd hh mm ss ...