Search code snippets, questions, articles...

How to get current date in Flutter [Dart]

In this tutorial, we'll show you how to get the current date in Flutter using the DateTime class. We'll also show you how to format the date and time to your liking.
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.

Flutter is a cross-platform mobile app development framework that allows developers to write a single codebase for both iOS and Android. Dart is used as the programming language to develop Flutter mobile applications.

The current date can be easily obtained in Flutter using the DateTime class. This class provides various methods for manipulating dates and times, such as getting the current date and time, adding or subtracting days or months, and more.

Get today's date with time using 

We can use the function to get the current date in Flutter. You do not need to import anything to use the DateTime module. This is an in-built module of Dart and you can use its now() function to get the current date with time.


Code example

DateTime current_date =;



2022-05-26 17:16:00.249516

Code example 2 - Convert DateTime to string

DateTime datetime =;
String dateStr = datetime.toString();

  1. The dart code above creates a new DateTime object using the now() method. 
  2. This method is used to get the current date along with the time
  3. The object is then converted to a string using the toString() method. 
  4. Finally, the string is printed to the console using the print() method.

Get the current date string without time [No package installation]

We can use the below code to get the current date in string format using the below code.

DateTime today =;
String dateStr = "${}-${today.month}-${today.year}";



  1. The code example above creates a new DateTime object containing the current date and time.
  2. Then stores it in the variable today
  3. It then creates a new string variable called dateStr, which contains the day, month, and year of the current date. 
  4. Finally, it prints the contents of dateStr to the console.

Get current date without time using intl package

Here, we will learn how to get the current date without time using the intl package. The intl package is a powerful standard library that provides many internationalization features, including date and time formatting.

First, install the intl package

  intl: ^0.17.0

Or you can also check the package here.

Second, import the package into your Flutter project,

import 'package:intl/intl.dart';

Finally, use the below code to get the current date in a specific format

Today's date in yyyy-mm-dd format

String currentDate = DateFormat('yyyy-MM-dd').format(;




Today's date in dd-mm-yyyy format

var today =;
var dateFormat = DateFormat('dd-MM-yyyy');
String currentDate = dateFormat.format(today);




Write the above code in single line

String currentDate = DateFormat('dd-MM-yyyy').format(;
  1. First, the above code declares a String variable named currentDate
  2. Then, the code uses the DateFormat class to format the current date as dd-MM-yyyy.
  3.  Finally, the code uses the print() function to print the current date to the console.
DateTime today =;
String dateStr = today.toString().substring(0, 10);

We can also use the substring() function to get the current date from
Was this helpful?