datex_formatter 1.0.0
datex_formatter: ^1.0.0 copied to clipboard
Lightweight DateTime formatting extensions for Dart and Flutter.
datex #
Lightweight DateTime formatting extensions for Dart and Flutter.
Features #
- Common date formats
- Common time formats
- DateTime formatting helpers
- String to DateTime conversion
- Custom format support using intl
Installation #
Add this to your pubspec.yaml:
dependencies:
datex: ^1.0.0
Then run:
dart pub get
or
flutter pub get
Usage #
Import the package:
import 'package:datex/datex.dart';
DateTime Extensions #
final now = DateTime.now();
print(now.yyyyMMdd); // 2026-06-04
print(now.ddMMyyyy); // 04-06-2026
print(now.ddMMMyyyy); // 04 Jun 2026
print(now.hhmm12); // 02:30 PM
print(now.hhmm24); // 14:30
print(now.dateTimeReadable); // 04 Jun 2026, 02:30 PM
Custom Format #
final now = DateTime.now();
print(now.format('dd/MM/yyyy'));
print(now.format('yyyy-MM-dd HH:mm:ss'));
String Extensions #
const apiDate = '2026-06-04T10:30:00Z';
print(apiDate.toDateTime());
print(apiDate.formatDate('dd MMM yyyy'));
Available Formats #
| Extension | Output |
|---|---|
| yyyyMMdd | 2026-06-04 |
| ddMMyyyy | 04-06-2026 |
| ddMMMyyyy | 04 Jun 2026 |
| ddMMMMyyyy | 04 June 2026 |
| hhmm12 | 02:30 PM |
| hhmm24 | 14:30 |
| dateTime24 | 2026-06-04 14:30:45 |
| fullDate | Thursday, 04 June 2026 |
| fullDateTime | Thursday, 04 June 2026, 02:30 PM |
| iso8601String | 2026-06-04T14:30:45.000 |
License #
MIT License