Current Date and Time

 import "package:celloip/splash_screen.dart";

import "package:flutter/material.dart";

void main() {
runApp(AppDemo(),);
}
class AppDemo extends StatelessWidget {
AppDemo({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Get Current Date & Time",
theme: ThemeData(
primarySwatch: Colors.brown,
),
// home: CurrentDateTime(),
home: SplashScreenDemo(),
);
}
}
class CurrentDateTime extends StatefulWidget {
CurrentDateTime({super.key});

@override
State<CurrentDateTime> createState() {
return CurrentDateTimeState();
}
}
class CurrentDateTimeState extends State<CurrentDateTime> {

@override
Widget build(BuildContext context) {

var time = DateTime.now();
return Scaffold(
drawer: Drawer(),
endDrawer: Drawer(),
appBar: AppBar(
title: Text("Current Date & Time"),
),
body: Center(
child: Container(
width: 300.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Current Time : ${time}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current ClockTime : ${time.hour} : ${time.minute} : ${time.second}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current Calendar Date:${time.day}/${time.month}/${time.year}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current Year : ${time.year}", style: TextStyle(fontSize: 20.0,),),
Text("Current Month : ${time.month}", style: TextStyle(fontSize: 20.0,),),
Text("Current Day : ${time.day}", style: TextStyle(fontSize: 20.0,),),
Text("Current Hour : ${time.hour}", style: TextStyle(fontSize: 20.0,),),
Text("Current Minute : ${time.minute}", style: TextStyle(fontSize: 20.0,),),
Text("Current Second : ${time.second}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current TimeZoneName : ${time.timeZoneName}", style: TextStyle(fontSize: 23.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current MicroSecond : ${time.microsecond}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current Millisecond : ${time.millisecond}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current Weekday : ${time.weekday}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current TimeZoneOffset: ${time.timeZoneOffset}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current MillisecondsSinceEpoch : ${time.millisecondsSinceEpoch}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current RunTimeType : ${time.runtimeType}", style: TextStyle(fontSize: 20.0,),),
Divider(thickness: 1.0, color: Colors.black,),
Text("Current toUtc : ${time.toUtc()}", style: TextStyle(fontSize: 20.0,),),
SizedBox(height: 10.0,),
ElevatedButton(
onPressed: () {
setState(() {},);
},
style: ElevatedButton.styleFrom(
fixedSize: Size(300.0, 60.0,),
backgroundColor: Colors.blue,
),
child: Text("Current Date & Time", style: TextStyle(fontSize: 25.0,),),
),
],
),
),
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter