Urgent.News

What's breaking now, across thousands of outlets.

AI

Node Date's epoch millisecond pit + using MCP to stuff the conversion into the AI stream

Node Date 的 epoch 毫秒坑 + 用 MCP 把转换塞进 AI 流 作者是 Node.js / JS 时间 方向的开发者。这篇不是广告,是踩坑记录 + 顺手做的工具。 背景 做 Node.js / JS 时间 时,时间戳转换是最常被低估的雷区。16 个时间戳工具(Unix 转换/时区/ISO8601/Cron/Duration…) 已覆盖日常;但每个语言/框架的坑都不一样,所以又补了 30 个语言/框架时间戳页(python/javascript/java/sql/…),每页含 6 个真实坑。 我踩过的坑(举几个) 秒 vs 毫秒:前端 Date.now() 是毫秒,后端常存秒,混用差 1000 倍。 时区不是字符串:存 UTC、展示本地,别把本地时间当 UTC 落库。 2038 问题:32 位系统 time_t 在 2038-01-19 溢出,老系统要提前查。…

Translated from Chinese Read in Chinese

Node Date's epoch millisecond pit + using MCP to integrate timestamp conversion into AI workflow I'm a Node.js/JS time developer. This article is not an advertisement, but a record of the pitfalls I've encountered and a tool I've created.

When working with Node.js/JS time, timestamp conversion is often underestimated as a minefield. Although 16 timestamp tools (Unix conversion/time zone/ISO8601/Cron/Duration...) have covered daily needs, each language/framework has its unique pitfalls. Therefore, I've added 30 language/framework timestamp pages (python/javascript/java/sql/...), each containing 6 real-world pitfalls.

Some of the pitfalls I've encountered include:

Seconds vs milliseconds: The frontend Date.now() returns milliseconds, while the backend often stores seconds, resulting in a 1000-fold difference when mixed.

Time zone is not a string: Store UTC and display local time; don't treat local time as UTC when storing.

2038 problem: The 32-bit system time_t overflows on 2038-01-19, so old systems need to be checked in advance.

Daylight Saving Time: There are two repeated/missing local times per year, which can be particularly problematic for cross-regional scheduling.

I've also created some tools:

A quick conversion reference page: https://gotimestamp.com/timestamp/nodejs

A related language page: https://gotimestamp.com/timestamp/javascript

An open-source MCP: https://github.com/caresotin/tsforge-mcp - which integrates timestamp conversion/validation directly into LLM workflows, eliminating manual calculations.

In conclusion, timestamp conversion is not as simple as it seems, but with the right tools, it can be hassle-free. All of the above resources are free, open-source, and directly usable, and I hope they help others who have encountered similar pitfalls.

Translated by urgent.news. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Monday 3 August →