{"id":43382,"library":"mysqldate","title":"mysqldate","description":"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.","status":"maintenance","version":"0.1.6","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/Okoyl/mysqldate","tags":["javascript","mysql","date","timestamp","datetime"],"install":[{"cmd":"npm install mysqldate","lang":"bash","label":"npm"},{"cmd":"yarn add mysqldate","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysqldate","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package modifies global Date.prototype; no named exports. Import for side effects only, then use Date methods directly.","wrong":"const mysqldate = require('mysqldate');","symbol":"mysqldate (side-effect)","correct":"import 'mysqldate';"},{"note":"Instance method on Date objects, not static on Date constructor.","wrong":"Date.toMysqlDate();","symbol":"toMysqlDate","correct":"new Date().toMysqlDate();"},{"note":"Static method on Date constructor, not on instances.","wrong":"new Date().fromMysqlDate('1979-03-28 23:45:37');","symbol":"fromMysqlDate","correct":"Date.fromMysqlDate('1979-03-28 23:45:37');"},{"note":"Also static method. Expects UTC string but returns local Date object.","wrong":"","symbol":"fromMysqlUTCDate","correct":"Date.fromMysqlUTCDate('2013-03-28 11:11:52');"}],"quickstart":{"code":"import 'mysqldate';\n\nconst now = new Date();\nconsole.log(now.toMysqlDate());       // '2025-01-15 10:30:00'\nconsole.log(now.toMysqlUTCDate());    // '2025-01-15 15:30:00'\n\nconst fromLocal = Date.fromMysqlDate('2025-01-15 10:30:00');\nconsole.log(fromLocal.toISOString()); // '2025-01-15T10:30:00.000Z' if local timezone UTC\n\nconst fromUTC = Date.fromMysqlUTCDate('2025-01-15 15:30:00');\nconsole.log(fromUTC.toISOString());   // '2025-01-15T15:30:00.000Z'","lang":"javascript","description":"Demonstrates converting Date to MySQL string and parsing MySQL string to Date using static and instance methods."},"warnings":[{"fix":"Use as standalone import only if no other Date polyfills are in use; isolate via module scoping if possible.","message":"Modifies Date.prototype globally, affecting all Date instances. May conflict with other libraries that also monkey-patch Date.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using modern alternatives like dayjs, date-fns, or luxon with MySQL format functions.","message":"Package last published in 2015; no longer maintained. Not compatible with ES modules in newer Node versions without proper polyfill.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Always pass UTC strings to fromMysqlUTCDate and local strings to fromMysqlDate. Verify by using toISOString() on result.","message":"fromMysqlDate parses string as local time; fromMysqlUTCDate also parses as local time despite name. Inconsistent behavior across systems.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If millisecond precision needed, format manually or use alternative library.","message":"toMysqlDate and toMysqlUTCDate do not zero-pad milliseconds; output is seconds precision only.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.1.6':21 '2015':25 'activ':48 'api':29 'conveni':44 'convert':10 'current':18 'date':5,12,39,58 'datetim':60 'depend':46 'differenti':34 'environ':55 'extend':2 'frommysqld':32 'frommysqlutcd':33 'import':43 'javascript':3,56 'last':22 'low':26 'maintain':49 'mainten':27 'may':50 'method':8 'minim':28 'modern':54 'monkey':36 'monkey-patch':35 'mysql':15,57 'mysqldat':1 'nativ':38 'need':51 'no-import':41 'object':13 'patch':37 'polyfil':52 'prototyp':6 'releas':23 'stabl':19 'string':17 'timestamp':16,59 'tomysqld':30 'tomysqlutcd':31 'version':20","created_at":"2026-06-05T16:59:31.848962+00:00","updated_at":"2026-06-05T16:59:31.848962+00:00","problems":[{"fix":"Add `import 'mysqldate';` at top of entry file. Ensure it is the first import if using module bundler.","cause":"Package not imported before calling method, or imported incorrectly.","error":"TypeError: (intermediate value).toMysqlDate is not a function"},{"fix":"Run `npm install mysqldate` and verify node_modules/mysqldate exists.","cause":"Package not installed or node_modules path issue.","error":"Error: Cannot find module 'mysqldate'"},{"fix":"Same fix as above: import side-effect before usage.","cause":"Package not imported, or static method called before import.","error":"Date.fromMysqlDate is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/Okoyl/mysqldate#readme","github":"ssh://git@github.com/Okoyl/mysqldate","docs":null,"changelog":null,"pypi":null,"npm":"mysqldate","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}