strftime is a JavaScript utility library that provides `strftime`-style date and time formatting, mimicking the functionality found in C's `strftime` function and Ruby's extensions. The current stable version is `0.10.3`, primarily receiving maintenance updates and bug fixes rather than active feature development. This is indicated by its infrequent release cadence since 2016's planned v1.0 release that never materialized. Key differentiators include its support for various format specifiers (including Ruby extensions), robust localization capabilities through custom locale objects or bundled identifiers, and timezone handling via offsets. It is designed to work both in Node.js environments and web browsers, offering a consistent API for formatting `Date` objects into human-readable strings. The library aims for broad compatibility, even supporting very old Node.js versions.
npm install strftimeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic date formatting, applying a custom locale, using a bundled locale identifier, and formatting dates with explicit timezone offsets using `strftime`.
Migrate any usage of `strftimeTZ` or `strftimeUT` to the unified `strftime.timezone(offset)` method, providing the timezone offset as minutes from GMT or an ISO 8601 string.
Review the `v0.9.0` changelog and updated usage examples to adapt to the new unified API. Specifically, be aware of changes related to timezone handling and the removal of previous functions like `strftimeTZ`.
Upgrade to `strftime` version `0.10.1` or newer. If precise short time zone names are critical and environment inconsistencies persist, consider using explicit `strftime.timezone(offset)` with carefully chosen format strings.
For Node.js CommonJS projects, use `const strftime = require('strftime');`. In ES Module projects, while `import strftime from 'strftime';` can sometimes work due to Node.js's interoperability, using a bundler like Webpack or Rollup often provides more consistent results when importing CJS modules into an ESM context. Alternatively, consider dynamic `import('strftime')` if suitable for your application logic.Ensure `strftime` is imported correctly as a function/object (e.g., `const strftime = require('strftime');`) and called directly or its methods (`strftime(...)`, `strftime.localize(...)`). Do not use `new` with `strftime`.In a file intended for ES Modules, ensure your `package.json` has `"type": "module"` or the file ends with `.mjs`. Use `import strftime from 'strftime';`. In a file intended for CommonJS, ensure `"type": "module"` is NOT in `package.json` or the file ends with `.cjs`. Then, use `const strftime = require('strftime');`.Upgrade the `strftime` package to version `0.10.2` or later to resolve the incorrect padding behavior for `%-y`.
No dependency data recorded yet.