datex_formatter 1.1.1
datex_formatter: ^1.1.1 copied to clipboard
Lightweight DateTime formatting and timezone conversion extensions for Dart and Flutter.
datex #
Lightweight DateTime formatting extensions for Dart and Flutter.
Features #
- Common date formats
- Common time formats
- DateTime formatting helpers
- Local timezone conversion support
- String to DateTime conversion
- Custom format support using
intl - Clean and easy-to-use extension methods
Installation #
Add this to your pubspec.yaml:
dependencies:
datex: ^1.0.0
Then run:
flutter pub get
or
dart pub get
Usage #
Import the package:
import 'package:datex/datex_formatter.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
Local Time Conversion #
Convert UTC or any DateTime object to the device's local timezone before formatting.
final utcDate = DateTime.parse('2026-06-04T10:30:00Z');
print(utcDate.ddMMyyyy);
print(utcDate.local.ddMMyyyy);
print(utcDate.hhmm12);
print(utcDate.local.hhmm12);
print(utcDate.dateTimeReadable);
print(utcDate.local.dateTimeReadable);
Custom Format #
final now = DateTime.now();
print(now.format('dd/MM/yyyy'));
print(now.format('yyyy-MM-dd HH:mm:ss'));
print(now.format('EEEE, dd MMMM yyyy'));
String Extensions #
const apiDate = '2026-06-04T10:30:00Z';
print(apiDate.toDateTime());
print(
apiDate
.toDateTime()
.local
.dateTimeReadable,
);
Available Formats #
Date Formats #
| Extension | Example Output |
|---|---|
| yyyyMMdd | 2026-06-04 |
| yyyyMMddCompact | 20260604 |
| ddMMyyyy | 04-06-2026 |
| ddMMyy | 04-06-26 |
| ddMMyyyySlash | 04/06/2026 |
| mmDdYyyy | 06/04/2026 |
| ddMMMyyyy | 04 Jun 2026 |
| ddMMMMyyyy | 04 June 2026 |
| mmmDdYyyy | Jun 04, 2026 |
| shortDayDate | Thu, 04 Jun 2026 |
| fullDate | Thursday, 04 June 2026 |
| ddMMM | 04 Jun |
| ddMMMM | 04 June |
| mmmDd | Jun 04 |
| mmmYyyy | Jun 2026 |
| mmmmYyyy | June 2026 |
Time Formats #
| Extension | Example Output |
|---|---|
| hhmm24 | 14:30 |
| hhmm12 | 02:30 PM |
| hhmmss24 | 14:30:45 |
| hhmmss12 | 02:30:45 PM |
DateTime Formats #
| Extension | Example Output |
|---|---|
| dateTime24 | 2026-06-04 14:30:45 |
| dateTimeReadable | 04 Jun 2026, 02:30 PM |
| fullDateTime | Thursday, 04 June 2026, 02:30 PM |
| dateTimeSlash24 | 04/06/2026 14:30 |
| dateTimeDash12 | 04-06-2026 02:30 PM |
Other Extensions #
| Extension | Example Output |
|---|---|
| dayName | Monday |
| dayShort | Mon |
| monthName | January |
| monthShort | Jan |
| year | 2026 |
| shortYear | 26 |
| iso8601String | 2026-06-04T14:30:45.000 |
Example #
final apiDate = DateTime.parse('2026-06-04T10:30:00Z');
final displayDate = apiDate.local.dateTimeReadable;
print(displayDate);
License #
This project is licensed under the MIT License.
Copyright (c) 2026 Sanket C Panchal
See the LICENSE file for details.