Registry / database / micro-timestamp

micro-timestamp

JSON →
library2.1.0jsnpmunverified

micro-timestamp is a lightweight Node.js package that generates UTC microsecond timestamps in MySQL datetime format (YYYY-MM-DD HH:MM:SS.ffffff). Current stable version 2.1.0 relies on the microtime library for high-resolution microsecond precision. It automatically adjusts for system timezone offset to ensure UTC correctness. Simpler than alternatives like moment.js for this specific use case, but has no TypeScript support and limited ecosystem adoption.

npm install micro-timestamp
INSTALL
IMPORT
SIG · MICRO-TIMESTAMP
M
micro-timestamp
databasejavascriptv2.1.0
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.

default (microTimestamp)
const microTimestamp = require('micro-timestamp');
import microTimestamp from 'micro-timestamp';
This package does not ship ES modules. It must be used with CommonJS require(). ESM-style import will fail.
microTimestamp
const microTimestamp = require('micro-timestamp');
const { microTimestamp } = require('micro-timestamp');
The package exports a single function as default. Named destructuring does not work.
microTimestamp function call
const ts = require('micro-timestamp')();
import microTimestamp from 'micro-timestamp'; const ts = microTimestamp();
The function is called immediately after require. Ensure no extra spaces or assignment to intermediate variable.

Shows CommonJS require, calling the function with no arguments, and example output with microsecond granularity.

const microTimestamp = require('micro-timestamp'); const ts = microTimestamp(); console.log(ts); // e.g., "2025-03-15 14:23:45.123456" // If you need timestamp for a specific moment, you cannot; it always returns current time.
Debug
Known issues
breakingIn version 2.0, the return format changed from ISO string '2018-11-11T11:11:11.111111Z' to MySQL format '2018-11-11 11:11:11.111111' (space instead of T and no Z).
fix
If you depend on the previous ISO format, either pin to version 1.x or manually transform the output.
affects: >=2.0
gotchaThe module uses the 'microtime' package, which requires native compilation (node-gyp). Installation may fail on systems without build tools.
fix
Ensure build essentials are installed (e.g., on Ubuntu: sudo apt-get install build-essential python3). Alternatively, use a fallback timestamp library without native dependencies.
affects: >=1.0
gotchaThe returned timestamp is always in UTC, but uses the system's local time to compute the offset. If the system timezone is incorrectly set, the timestamp may be inaccurate.
fix
Verify system timezone is correct (e.g., use `date` command). The package does no timezone database lookups; it assumes the system's offset is accurate.
affects: >=1.0
deprecatedAs of Node.js 16, process.hrtime() provides high-resolution time without native addons. The 'microtime' dependency may become obsolete.
fix
Consider switching to a native implementation using process.hrtime.bigint() and converting to microseconds.
affects: >=2.0
Errors
Common errors & fixes
Error: Cannot find module 'micro-timestamp'
The package is not installed or is installed globally but expected locally.
fix
Run 'npm install micro-timestamp' in your project directory.
TypeError: require(...) is not a function
Using destructuring assignment (const { microTimestamp } = require('micro-timestamp')) on a default export.
fix
Use 'const microTimestamp = require('micro-timestamp');' without curly braces.
Error: Module not found: Can't resolve 'micro-timestamp' in '<project>'
Attempting to import the package in an ESM context (e.g., using import statement in Node or bundler).
fix
Use CommonJS require() or configure your bundler to handle CommonJS modules. Do NOT use import.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
microtimerequiredUsed to obtain microsecond-precision timestamps from the system.
Agent activity
9 hits · last 30 days
node
6
Amazon
1
Resources
micro-timestamp — npm install micro-timestamp · libregistry