Registry / productivity / little-time

little-time

JSON →
library1.1.12jsnpmunverified

Minimalist timestamp manipulator and formatter inspired by moment.js, providing time formatting, relative times (e.g., '5 minutes ago'), and UTC support in ~1.5KB gzipped. Stable version 1.1.12 (last released in 2021), low maintenance cadence. Differentiators: tiny footprint, same function signatures as moment.js for easy drop-in replacement, supports Node.js >=0.10.25 and browsers.

npm install little-time
INSTALL
IMPORT
SIG · LITTLE-TIME
L
little-time
productivityjavascriptv1.1.12
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

littleTime
import littleTime from 'little-time'
const littleTime = require('little-time')
Default CommonJS require works but TypeScript may need esModuleInterop. ESM wrapper might be needed in bundlers.
littleTime.format
littleTime().format('ddd MMM Do YYYY')
littleTime.format('ddd MMM Do YYYY')
format() is an instance method, not static. You must call littleTime() first.
littleTime.utc
const lt = littleTime.utc('2016-08-28 12:00:00-07:00'); lt.format()
littleTime.utc.format('...')
littleTime.utc() is a static method returning an instance. It is not a namespace for format.

Demonstrates basic formatting, custom format tokens, relative time calculations, and UTC conversion.

import littleTime from 'little-time'; // Current time format (default) console.log(littleTime().format()); // '2021-10-05T12:00:00Z' // Custom format console.log(littleTime('2021-10-05').format('ddd MMM Do YYYY')); // 'Tue Oct 5th 2021' // Relative time from now console.log(littleTime(Date.now() - 3600000).fromNow()); // '1 hour ago' // Duration between two times const start = littleTime('2021-10-05 10:00:00'); const end = littleTime('2021-10-05 18:00:00'); console.log(end.from(start, true)); // '8 hours' // UTC support const utcTime = littleTime.utc('2021-10-05 12:00:00+02:00'); console.log(utcTime.format()); // '2021-10-05T10:00:00Z'
Debug
Known issues
breakingAPI changed from version 0.x to 1.0.0. Many formatter changes and fixes.
fix
Update code to use the new 1.0.0 API, especially for custom format tokens (check changelog).
affects: >=0.1.0 <1.0.0
deprecatedThe package has not seen updates since 2021. It may become incompatible with future JavaScript environments.
fix
Consider migrating to a more maintained library like dayjs or date-fns for long-term projects.
affects: >=1.1.12
gotchaBrowser usage requires bundler or <script> tag with a UMD build. The package does not ship a standalone browser bundle.
fix
Use a bundler (Webpack, Rollup) or import via CDN (e.g., unpkg) noting it expects CommonJS.
affects: >=1.0.0
gotchaTypeScript definitions are not included. Users must write custom type declarations.
fix
Create a little-time.d.ts file or use @ts-ignore.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: littleTime.format is not a function
Calling format as a static method on the imported function instead of an instance method.
fix
Call littleTime().format() instead of littleTime.format().
Uncaught ReferenceError: littleTime is not defined
Using littleTime in a browser without proper import or script tag.
fix
Use <script src="node_modules/little-time/index.js"></script> or bundle with a module loader.
Error: Cannot find module 'little-time'
Package not installed or misspelled in require/import.
fix
Run 'npm install little-time' and verify package.json has the dependency.
Upgrade
Version history
1.1.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
little-time — npm install little-time · libregistry