A simple package that helps in formatting date and time from a given DateTime object.

Features

Convert Datetime to String with desired format effortlessly.

Getting started

flutter pub add format_date

Usage

import 'package:format_date/format_date.dart';

void main(){
    runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({super.key});
  DateTime currentDateTime = DateTime.now();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(
            children: [
                Text(
                    FormatDate.formatDate(dateTime: currentDateTime,), //dd-mm-yyyy
                );
                Text(
                    FormatDate.formatDate(dateTime: currentDateTime, format: 'dd/mm'),
                );
                Text(
                    FormatDate.formatTime(dateTime: currentDateTime,), //hh:mm:ss
                );
                Text(
                    FormatDate.formatTime(dateTime: currentDateTime, format: 'hh:mm'),
                );
            ]
        ),
    );
  }
}




Additional information

For more information: https://github.com/gru786/format_date

Libraries

format_date