import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
void main() {
runApp(dateDemo());
}
class dateDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Date-Demo",
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.green.shade900,
foregroundColor: Colors.white,
title: Text("Geeksforgeeks"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Day,Month Date,Year
Text(
DateFormat.yMMMEd().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// Day,Month/Date in Numbers
Text(
DateFormat.MEd().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// DayName,MonthName Date
Text(
DateFormat.MMMMEEEEd().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// DayName,MonthName Date,Year
Text(
DateFormat.yMMMMEEEEd().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// Full DayName only
Text(
DateFormat.EEEE().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// Short DayName
Text(
DateFormat.E().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// Month-Number
Text(
DateFormat.M().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// short MonthName
Text(
DateFormat.MMM().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// full MonthName
Text(
DateFormat.LLLL().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// Current Time only
Text(
DateFormat.j().format(DateTime.now()),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
],
),
),
),
);
}
}