chronos_formatter
A simple and flexible DateTime formatter for Dart & Flutter.
Format dates and times with custom order, padding, 12H/24H system, and more.
β¨ Features
- Format
DateTimewith custom order:DMY,MDY,YMD. - Support for 12H / 24H system with AM/PM.
- Add optional seconds and leading zeros.
- Control output with
showDateandwithHours. - Throws exception if both
showDateandwithHoursarefalse.
π¦ Installation
Add this line to your pubspec.yaml:
dependencies:
chronos_formatter: ^0.0.1
Then run:
flutter pub get
π Usage
import 'package:chronos_formatter/chronos_formatter.dart';
final now = DateTime(2025, 9, 4, 15, 7, 9);
// Date + Time
print(ChronosFormatter.format(
now,
order: DateOrder.mdy,
withHours: true,
is12HSystem: true,
));
// 09/04/2025 03:07 PM
// Date only
print(ChronosFormatter.format(now, order: DateOrder.ymd));
// 2025/09/04
// Time only
print(ChronosFormatter.format(now, showDate: false, withHours: true));
// 15:07
π§ͺ Running tests
flutter test
π License
This project is licensed under the MIT License.