format_date 0.0.5
format_date: ^0.0.5 copied to clipboard
To be able to format dates, all you need is to provide a datetime object and a desired formatting as String, as input to one of the two functions - formatDate or formatTime.
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