DateFormat Flutter I am fetching date form json api "2020-04-18T00:00:00" in this format but i want in this format "dd-mm-yyyy"

sayed huzefa

I am fetching Date From json api which is in this format 2020-04-18T00:00:00 but i want date in this format dd-mm-yy

String date=pALResponse.clmmDate;
DateFormat("dd-MM-yyyy").parse(date);
void

You can use the intl package (installer) to format dates in Flutter.

See an example code below:

import 'package:intl/intl.dart';

main() {
  var now = new DateTime.now();
  var formatter = new DateFormat('yyyy-MM-dd');
  String formatted = formatter.format(now);
  print(formatted); // something like 2013-04-20
}

There are many options for formatting. From the docs:

 ICU Name                   Skeleton
 --------                   --------
 DAY                          d
 ABBR_WEEKDAY                 E
 WEEKDAY                      EEEE
 ABBR_STANDALONE_MONTH        LLL
 STANDALONE_MONTH             LLLL
 NUM_MONTH                    M
 NUM_MONTH_DAY                Md
 NUM_MONTH_WEEKDAY_DAY        MEd
 ABBR_MONTH                   MMM
 ABBR_MONTH_DAY               MMMd
 ABBR_MONTH_WEEKDAY_DAY       MMMEd
 MONTH                        MMMM
 MONTH_DAY                    MMMMd
 MONTH_WEEKDAY_DAY            MMMMEEEEd
 ABBR_QUARTER                 QQQ
 QUARTER                      QQQQ
 YEAR                         y
 YEAR_NUM_MONTH               yM
 YEAR_NUM_MONTH_DAY           yMd
 YEAR_NUM_MONTH_WEEKDAY_DAY   yMEd
 YEAR_ABBR_MONTH              yMMM
 YEAR_ABBR_MONTH_DAY          yMMMd
 YEAR_ABBR_MONTH_WEEKDAY_DAY  yMMMEd
 YEAR_MONTH                   yMMMM
 YEAR_MONTH_DAY               yMMMMd
 YEAR_MONTH_WEEKDAY_DAY       yMMMMEEEEd
 YEAR_ABBR_QUARTER            yQQQ
 YEAR_QUARTER                 yQQQQ
 HOUR24                       H
 HOUR24_MINUTE                Hm
 HOUR24_MINUTE_SECOND         Hms
 HOUR                         j
 HOUR_MINUTE                  jm
 HOUR_MINUTE_SECOND           jms
 HOUR_MINUTE_GENERIC_TZ       jmv
 HOUR_MINUTE_TZ               jmz
 HOUR_GENERIC_TZ              jv
 HOUR_TZ                      jz
 MINUTE                       m
 MINUTE_SECOND                ms
 SECOND                       s

See https://www.dartdocs.org/documentation/intl/latest/intl/DateFormat-class.html for more info.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I want to ask date from User in DD/MM/YYYY format and I want to insert '/' automatically after DD or MM or YYYY

how to i change the format of date from dd-mm-yyyy to dd/mm/yyyy in a csv file

I have date with this format in my db '1631363150' i want to change it to dd-mm-yyyy (DART)

I am trying date format mm/dd/yyyy to dd/mm/yyyy in input type date

How do I display a date format in dd/MM/yyyy to ddd, dd/MM/yyyy (Mon, 1/4/2014) format with this logic?

Multiple date formats in tbl_spark in R. I want to change all the date formats to one format (dd-mm-yyyy)

How do I convert String date to Date format date in dd-MM-yyyy format in java

Date Time format in Flutter dd/MM/YYYY hh:mm

I want to insert datetime to database by converting the format to 'DD-MM-YYYY'

How do I get the current Date/time in DD/MM/YYYY HH:MM format?

How to group by year when I have a columns named date in the format dd/mm/yyyy

How do I convert "dd.mm.yyyy" string to date format in golang?

How can I place a date in dd/mm/yyyy format into an Excel cell with VBA?

I need to change date format from dd-MM-yyyy to yyyy-MM-DD

How could I change the date format in android from dd-MM-yyyy HH:mm:ss to only dd-MM-yyyy HH:mm?

how can i validate data in dd-mm-yyyy format

How do I change format datetime in HTML to dd/mm/yyyy

angular converting the date in dd/mm/yyyy format

Javascript change date into format of (dd/mm/yyyy)

Regex to validate date format dd/mm/yyyy

Format date as dd/MM/yyyy using pipes

Pymongo date query in "DD/MM/YYYY" format

javascript date format into dd/mm/yyyy

Convert dd/mm/yyyy H to date format

django how to format date to DD/MM/YYYY

Date format to dd/mm/yyyy in a single object

Insert date in dd-MM-yyyy format

Saving date in yyyy-MM-dd format into SQL Server 2008 if I passed date in dd-MM-yyyy format

How can I avoid getting this error while parsing an input date with this format dd/mm/yyyy to yyyy-mm-dd?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive