close

How to get current Date time in flutter?

Hello Guys How are you all? Hope you all are fine. Today in this tutorial we are going to learn How to get current Date time in flutter? So lets start this article without wasting your time.

How to get current Date time in flutter?

  1. How to get current Date time in flutter?

    To get current Date time in flutter Here we are going to use DateFormat class of flutter To get the current Time in AM/PM format. DateFormat is for formatting and parsing dates in a locale-sensitive manner. It allows the user to choose from a set of standard date time formats as well as specify a customized pattern under certain locales. Date elements that vary across locales include month name, week name, field order, etc. We also allow the user to use any customized pattern to parse or format date-time strings under certain locales. Date elements that vary across locales include month name, weekname, field, order, etc.

  2. get current Date time in flutter

    To get current Date time in flutter Here we are going to use DateFormat class of flutter To get the current Time in AM/PM format. DateFormat is for formatting and parsing dates in a locale-sensitive manner. It allows the user to choose from a set of standard date time formats as well as specify a customized pattern under certain locales. Date elements that vary across locales include month name, week name, field order, etc. We also allow the user to use any customized pattern to parse or format date-time strings under certain locales. Date elements that vary across locales include month name, weekname, field, order, etc.

Method 1: current Time in AM/PM format

DateFormat is for formatting and parsing dates in a locale-sensitive manner. It allows the user to choose from a set of standard date time formats as well as specify a customized pattern under certain locales. Date elements that vary across locales include month name, week name, field order, etc. We also allow the user to use any customized pattern to parse or format date-time strings under certain locales. Date elements that vary across locales include month name, weekname, field, order, etc.

Add intl package to your pubspec.yaml file.

import 'package:intl/intl.dart';

DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");

Here we are going to use DateFormat class of flutter To get the current Time in AM/PM format.

dynamic currentTime = DateFormat.jm().format(DateTime.now());

Method 2: Current datetime

DateTime now = DateTime.now();
print(now.hour.toString() + ":" + now.minute.toString() + ":" + now.second.toString());

Method 3: Current datetime format

String formattedDate = DateFormat('kk:mm:ss \n EEE d MMM').format(now);

Summery

So, It’s All About Progress indicator in snackbar in flutter. I hope this tutorial helps you to solve your error. Please Comment Below if You stucks anywhere with my code.

Also Check Out Below Tutorials

Leave a Comment

%d bloggers like this: