Docs
Basic Usage
Formatting, parsing, manipulation, and duration examples using mmntjs/lite, the recommended entry point for most teams.
Guidance
Use mmntjs/lite As The Default Entry Point
mmntjs/lite is the recommended starting point for most teams. It provides method chaining, basic formatting (YYYY-MM-DD, HH:mm:ss), ISO parsing, add/subtract, startOf/endOf, diff, and comparison. That covers the majority of moment.js usage patterns at 55.2KB raw bundled.
Import additional capabilities explicitly when you need them: add plugin/format-parse for custom format strings, plugin/utc for UTC and parseZone support, or locale/* for localized output. This keeps your bundle lean and makes dependencies visible in review.
- Start every new module or browser entry point with
mmntjs/lite. - Only switch to the default
mmntjsentry when full-compat features and locale-rich formatting are required without explicit plugin imports. - Use
mmntjs/fnsfor standalone function style when tree-shaking matters most.
Stay Close To Existing Moment Call Patterns At First
Basic usage examples should reassure evaluators that common moment-style creation, formatting, arithmetic, and duration flows still read naturally.
The first migration phase is usually about preserving behavior and minimizing review noise, not about rewriting every date call into a new style immediately.
- Prefer examples that look like current moment code.
- Use a mix of formatting, UTC, add/subtract, and duration examples.
- Link out quickly when behavior becomes parsing- or timezone-sensitive.
Examples
Formatting and arithmetic
import moment from "mmntjs";
const invoiceDate = moment("2024-01-01");
const dueDate = invoiceDate.clone().add(30, "days");
dueDate.format("YYYY-MM-DD");This is the kind of low-drama example teams want to see first during a migration review.
UTC flow
import moment from "mmntjs";
moment.utc("2024-06-15T12:30:00Z").format("YYYY-MM-DD HH:mm:ss");Useful as a first check when the application already relies on explicit UTC handling.
Duration example
import moment from "mmntjs";
moment.duration(2, "hours").humanize();Keep examples short and recognizable before diving into compatibility-sensitive details.
How To Use This Doc
Use this page as a migration review aid rather than as a generic tutorial. If the behavior in this area is business-critical, compare it directly against your current moment.js usage and record the outcome before expanding rollout.