date_format 1.0.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 76

date_format

A simple API to format dates.

Usage

Use formatDate function to format a DateTime

print(formatDate(new DateTime(1989, 02, 21), [yyyy, '-', mm, '-', dd]));

Output:

1989-02-21

Long month names

print(formatDate(new DateTime(1989, 2, 21), [yy, '-', M, '-', d]));

Output:

89-feb-21

Time parts

print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss]));

Output:

15:40:10

Timezone

print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, z]));

Output:

15:40:10+0100

Changelog

1.0.4

  • Capital letters

1.0.2

  • Fixed negative timezone bug

1.0.1

  • Docs
  • Added microsecond

1.0.0

  • formatDate

example/date_format_example.dart

import 'package:date_format/date_format.dart';

main() {
  print(formatDate(new DateTime(1989, 2, 21), [yyyy, '-', mm, '-', dd]));
  print(formatDate(new DateTime(1989, 2, 21), [yy, '-', m, '-', dd]));
  print(formatDate(new DateTime(1989, 2, 1), [yy, '-', m, '-', d]));

  print(formatDate(new DateTime(1989, 2, 1), [yy, '-', MM, '-', d]));
  print(formatDate(new DateTime(1989, 2, 21), [yy, '-', M, '-', d]));

  print(formatDate(new DateTime(1989, 2, 1), [yy, '-', M, '-', d]));

  print(formatDate(new DateTime(2018, 1, 14), [yy, '-', M, '-', DD]));
  print(formatDate(new DateTime(2018, 1, 14), [yy, '-', M, '-', D]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [hh, ':', nn, ':', ss, ' ', am]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [hh, ':', nn, ':', ss, ' ', am]));

  print(formatDate(new DateTime(1989, 02, 1, 15, 40, 10), [hh]));
  print(formatDate(new DateTime(1989, 02, 1, 15, 40, 10), [h]));

  print(formatDate(new DateTime(1989, 02, 1, 5), [am]));
  print(formatDate(new DateTime(1989, 02, 1, 15), [am]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, z]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, ' ', Z]));

  print(formatDate(new DateTime(1989, 02, 21), [yy, ' ', w]));
  print(formatDate(new DateTime(1989, 02, 21), [yy, ' ', W]));

  print(formatDate(new DateTime(1989, 12, 31), [yy, '-W', W]));
  print(formatDate(new DateTime(1989, 1, 1), [yy, '-', mm, '-w', W]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, ' ', Z]));
}

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  date_format: "^1.0.4"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:date_format/date_format.dart';
        
Version Uploaded Documentation Archive
1.0.4 Jan 25, 2018 Go to the documentation of date_format 1.0.4 Download date_format 1.0.4 archive
1.0.2 Jan 14, 2018 Go to the documentation of date_format 1.0.2 Download date_format 1.0.2 archive
1.0.1 Jan 14, 2018 Go to the documentation of date_format 1.0.1 Download date_format 1.0.1 archive
1.0.0 Jan 14, 2018 Go to the documentation of date_format 1.0.0 Download date_format 1.0.0 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
53 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
76

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:date_format/date_format.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
Dev dependencies
test ^0.12.0