搜尋套件、儲存庫與 APP 分類

套件詳情v2.0.9

date_format

一個簡單的 API 用於格式化日期。提供各種常數來建立日期格式字串。使用 `formatDate` 方法根據格式字串格式化日期。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
22.9萬
喜歡數
449
Pub 分數
150

安裝套件

flutter pub add date_format

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個輕量級的 Flutter 套件,透過乾淨的 API 簡化日期格式化。它提供常用日期格式的預設常數,並允許使用 `formatDate` 方法進行自訂格式化。非常適合需要在各平台上保持一致且易讀日期輸出的開發者。此套件支援所有主要平台,包括行動裝置、Web 和桌面,讓它成為跨平台應用的多功能選擇。它專注於簡單與易用,無需複雜設定。

適用情境

  • 在使用者介面上格式化日期
  • 產生標準化日期字串
  • 在應用程式中顯示時間戳
  • 國際化日期格式
  • 簡化日期字串的建立
  • 跨平台日期處理

主要特色

  • 預定義格式常數
  • 透過 `formatDate` 支援自訂格式
  • 多平台相容性
  • 簡單直覺的 API
  • 輕量且快速
  • 無外部依賴

適合對象

  • 初學者 Flutter 開發者
  • 需要一致日期顯示的應用程式
  • 跨平台專案
  • 需要格式化日期的 UI 元件
  • 尋求最小化設定的開發者

使用建議

  • 僅限基本日期格式化
  • 無內建的本地化支援
  • 不顯式處理時區
  • 最適合簡單的格式化需求
  • 需要手動處理區域設定相關的格式

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

date_format

A simple API to format dates.

Usage

Use formatDate function to format a DateTime object.

print(formatDate(DateTime(1989, 02, 21), [yyyy, '-', mm, '-', dd]));

Output:

1989-02-21

Long month names
print(formatDate(DateTime(1989, 2, 21), [yy, '-', M, '-', d]));

Output:

89-feb-21

Time parts
print(formatDate(
      DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss]));

Output:

15:40:10

Timezone
print(formatDate(
      DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, z]));

Output:

15:40:10+0100

所屬分類

原始碼儲存庫

使用此套件的專案