日期格式器 NSDateFormatter

2021-08-09 06:45:40 字數 654 閱讀 7501

nsdateformatter代表乙個日期格式器,它可以完成nsdate與nsstring之間的轉換。使用nsdateformatter完成nsdate與nsstring之間轉換的步驟如下:

1⃣️建立乙個nsdateformatter物件。

2⃣️呼叫nsdateformatter的setdatestyle: ,settimestyle:方法設定格式化日期,時間的風格。其中,日期,時間風格支援如下幾個列舉值。-->nsdateformatternostyle: 不顯示日期,時間的風格。-->nsdateformattershortstyle: 顯示「短」的日期,時間風格。-->nsdateformattermediumstyle: 顯示「中等」的日期,時間風格。-->nsdateformatterlongstyle: 顯示「長」的日期,時間風格。-->nsdateformatterfullstyle: 顯示「完整」的日期,時間格式。如果打算使用自己的格式模版,可以呼叫nsdateformatter的setdateformatter: 方法設定日期,時間的模版。

3⃣️如果需要講nsdate轉換為nsstring,呼叫nsdateformatter的stringfromdate: 方法執行格式化即可;如果需要講nsstring轉換為nsdate,呼叫nsdateformatter的datefromstring: 方法執行格式化即可。

elementUI日期選擇器,對日期格式進行處理

使用elementui日期選擇器中,獲取不同格式的時間 v model ruleform.zeroing type date type datetime value format timestamp style width 240px placeholder 選擇日期 value format yy...

python 日期 格式轉換 英文 日期格式轉換

一 date型轉字串 filter date date,yyyymm filter date time,hh mm 在控制器中使用必須注入 filter 模組 scope.dt1 new date 控制器中使用 scope.dt2 filter date scope.dt1,yyyy mm dd h...

Oracle日期格式

日期處理完全版 to date格式 day dd number 12 dy abbreviated fri day spelled out friday ddspth spelled out,ordinal twelfth month mm number 03 mon abbreviated mar...