Registry / devops / s-date

s-date

JSON →
library1.6.4jsnpmunverified

Tiny date/time formatter (~1KB minified) with a simple template-based API. Current stable version is 1.6.4, with no updates since 2020. It is in maintenance mode. It provides Moment.js-like formatting strings (e.g., {yyyy}, {mm}, {Month}) but at a fraction of the size. Unlike Luxon or date-fns, it focuses on minimal bundle size and straightforward formatting. It ships with TypeScript declarations, supports both CommonJS and ES module via conditional exports.

npm install s-date
INSTALL
IMPORT
SIG · S-DATE
S
s-date
devopsjavascriptv1.6.4
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.

date
import date from 's-date'
import { date } from 's-date'
Default export only; re-export as any name (e.g., format).
require
const date = require('s-date')
const { date } = require('s-date')
CommonJS usage since v1.0.0.
TypeScript usage
import date from 's-date'; const formatted: string = date('{yyyy}-{mm}-{dd}');
const date: any = require('s-date');
TypeScript types ship with the package; default import works with esModuleInterop.

Shows basic usage with default import, format string with tokens, and passing a Date object.

import date from 's-date'; // Format current date const now = date('{Month} {dd}, {yyyy} {h}:{Minutes}{ampm}'); console.log(now); // e.g., Oct 07, 2024 3:45pm // Format specific date const myBirthday = new Date(1994, 10, 7); const formatted = date('{yyyy}/{mm}/{dd}', myBirthday); console.log(formatted); // '1994/11/07'
Debug
Known issues
gotchaDate object's month is zero-indexed (0 = January). Incorrect usage leads to off-by-one month.
fix
Use new Date(year, monthIndex, day) with monthIndex = actualMonth - 1.
affects: >=1.0.0
deprecatedPackage is in maintenance mode; no new features or updates since 2020. May have security issues that remain unpatched.
fix
Consider migrating to actively maintained libraries like date-fns or dayjs for broader support.
affects: >=1.0.0
gotchaThe string template uses curly braces { } around tokens like {yyyy}. Using wrong casing (e.g., {YYYY}) produces no replacement.
fix
Use exact token names as documented: lowercase for most, {Month}, {Weekday}, etc. with capital first letter.
affects: >=1.0.0
gotchaThe library expects a format string as first parameter. Omitting it or passing undefined results in unexpected output (empty string or error).
fix
Always provide a format string. Example: date('{yyyy}-{mm}-{dd}', new Date())
affects: >=1.0.0
Errors
Common errors & fixes
Error: date is not a function
Using named import instead of default import: import { date } from 's-date' instead of import date from 's-date'
fix
Use default import: import date from 's-date'
Cannot find module 's-date' or its corresponding type declarations.
TypeScript project may need esModuleInterop enabled or moduleResolution set to 'node' or 'bundler'.
fix
Set 'esModuleInterop': true in tsconfig.json and use import date from 's-date'.
TypeError: date(...) is not a function
Using require incorrectly: const { date } = require('s-date')
fix
Use const date = require('s-date')
Upgrade
Version history
1.6.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
packages-date
s-date — npm install s-date · libregistry