chronos_formatter

pub package License: MIT

A simple and flexible DateTime formatter for Dart & Flutter.
Format dates and times with custom order, padding, 12H/24H system, and more.


✨ Features

  • Format DateTime with custom order: DMY, MDY, YMD.
  • Support for 12H / 24H system with AM/PM.
  • Add optional seconds and leading zeros.
  • Control output with showDate and withHours.
  • Throws exception if both showDate and withHours are false.

πŸ“¦ 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.

Libraries

chronos_formatter