strnow
v2.0.0
Published
Get current date and time formatted as YYYY-MM-DD HH:mm:ss
Maintainers
Readme
strnow
Returns current date and time in YYYY-MM-DD HH:mm:ss format – simple and lightweight.
Fully supports ESM and CommonJS (dual package), using the latest version of date-and-time.
Installation
npm install strnowyarn add strnowUsage
ESM (import) — Recommended
import strnow from 'strnow';
console.log(strnow.get());
// Output: 2026-04-05 14:30:25
// Or using named import
import { get } from 'strnow';
console.log(get());
// Output: 2026-04-05 14:30:25CommonJS (require)
const strnow = require('strnow');
console.log(strnow.get());
// Output: 2026-04-05 14:30:25TypeScript
Type definitions are included.
import strnow from 'strnow';
// or
import { get } from 'strnow';
const now: string = strnow.get();
console.log(now);API
| Method | Description | Returns |
|----------------|--------------------------------------|---------|
| get() | Returns formatted current date/time | string |
| default.get()| Alias for compatibility | string |
Fixed format: YYYY-MM-DD HH:mm:ss (e.g., 2026-04-05 14:30:25)
Why strnow?
- ✅ Extremely lightweight – minimal wrapper
- ✅ Dual module (ESM + CommonJS) – works in any Node.js project
- ✅ Zero configuration – minimal, predictable API
- ✅ Single well-maintained dependency:
date-and-time - ✅ Tested and compatible with Node.js 18+
License
MIT © marceloxp
