Registry / database / mysqldate

mysqldate

JSON →
library0.1.6jsnpmunverified

Extends JavaScript's Date prototype with methods to convert between Date objects and MySQL timestamp strings. Current stable version 0.1.6 (last released in 2015). Low maintenance, minimal API: toMysqlDate, toMysqlUTCDate, fromMysqlDate, fromMysqlUTCDate. Differentiator: monkey-patches native Date for no-import convenience; no dependencies. Not actively maintained, may need polyfills in modern environments.

npm install mysqldate
INSTALL
IMPORT
SIG · MYSQLDATE
M
mysqldate
databasejavascriptv0.1.6
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.

mysqldate (side-effect)
import 'mysqldate';
const mysqldate = require('mysqldate');
Package modifies global Date.prototype; no named exports. Import for side effects only, then use Date methods directly.
toMysqlDate
new Date().toMysqlDate();
Date.toMysqlDate();
Instance method on Date objects, not static on Date constructor.
fromMysqlDate
Date.fromMysqlDate('1979-03-28 23:45:37');
new Date().fromMysqlDate('1979-03-28 23:45:37');
Static method on Date constructor, not on instances.
fromMysqlUTCDate
Date.fromMysqlUTCDate('2013-03-28 11:11:52');
Also static method. Expects UTC string but returns local Date object.

Demonstrates converting Date to MySQL string and parsing MySQL string to Date using static and instance methods.

import 'mysqldate'; const now = new Date(); console.log(now.toMysqlDate()); // '2025-01-15 10:30:00' console.log(now.toMysqlUTCDate()); // '2025-01-15 15:30:00' const fromLocal = Date.fromMysqlDate('2025-01-15 10:30:00'); console.log(fromLocal.toISOString()); // '2025-01-15T10:30:00.000Z' if local timezone UTC const fromUTC = Date.fromMysqlUTCDate('2025-01-15 15:30:00'); console.log(fromUTC.toISOString()); // '2025-01-15T15:30:00.000Z'
Debug
Known issues
gotchaModifies Date.prototype globally, affecting all Date instances. May conflict with other libraries that also monkey-patch Date.
fix
Use as standalone import only if no other Date polyfills are in use; isolate via module scoping if possible.
affects: >=0.0.0
deprecatedPackage last published in 2015; no longer maintained. Not compatible with ES modules in newer Node versions without proper polyfill.
fix
Consider using modern alternatives like dayjs, date-fns, or luxon with MySQL format functions.
affects: >=0.0.0
gotchafromMysqlDate parses string as local time; fromMysqlUTCDate also parses as local time despite name. Inconsistent behavior across systems.
fix
Always pass UTC strings to fromMysqlUTCDate and local strings to fromMysqlDate. Verify by using toISOString() on result.
affects: >=0.0.0
gotchatoMysqlDate and toMysqlUTCDate do not zero-pad milliseconds; output is seconds precision only.
fix
If millisecond precision needed, format manually or use alternative library.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: (intermediate value).toMysqlDate is not a function
Package not imported before calling method, or imported incorrectly.
fix
Add `import 'mysqldate';` at top of entry file. Ensure it is the first import if using module bundler.
Error: Cannot find module 'mysqldate'
Package not installed or node_modules path issue.
fix
Run `npm install mysqldate` and verify node_modules/mysqldate exists.
Date.fromMysqlDate is not a function
Package not imported, or static method called before import.
fix
Same fix as above: import side-effect before usage.
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
mysqldate — npm install mysqldate · libregistry