Skip to content
pubscout

moment_dart

5.3.4, released 7 months ago by dev.gege.mn

Multi-purpose immutable DateTime subclass with support for multiple localizations and human-readable formats

WASM-ready
$ flutter pub add moment_dart
Source repository

What it does

Provides an immutable subclass of DateTime inspired by moment.js for converting DateTimes and Durations into human-readable relative formats, handling localizations, and providing various helper methods for date manipulation.

AI-written summary of version 5.3.4, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to display relative time strings like 'a day ago' or 'in 5 seconds'.
  • Your app requires robust multi-language localization support for dates and durations.
  • You want immutable DateTime instances with convenience methods for week, year, and range operations.

Skip it when

  • You only need basic, unlocalized Dart core DateTime manipulation without any formatting overhead.

Strengths

  • Supports multiple localizations out of the box.
  • Implements precise and relative duration formatting.
  • Provides numerous helper methods and extension-like features on DateTime and Duration.

Weaknesses

  • Adds an external dependency on a custom DateTime subclass instead of using core types directly.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0

none

final yesterday = Moment.now() - const Duration(days: 1);
yesterday.fromNow(); // a day ago

Alternatives

Packages that do the same job and could replace moment_dart.

  • zxing2

    Pure Dart library for encoding and decoding QR codes.

  • time

    Type-safe DateTime and Duration calculations, powered by extensions.

  • smart_date_formatter

    Flutter utility for formatting, parsing and manipulating DateTime with human‑readable strings and ready‑made widgets.

  • flutter_timeago_pro

    Formats nullable DateTime into human‑friendly relative or absolute timestamps.