date_format 1.0.4 copy "date_format: ^1.0.4" to clipboard
date_format: ^1.0.4 copied to clipboard

outdatedDart 1 only

A simple API to format dates.

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]));
}
433
likes
0
pub points
99%
popularity

Publisher

unverified uploader

A simple API to format dates.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on date_format