{
  "id": 6719918,
  "title": "How to Get Unix Timestamp in JavaScript (Seconds vs Milliseconds)",
  "url": "https://urgent.news/2026/09/11/how-to-get-unix-timestamp-in-javascript-seconds-vs-milliseconds",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-11T06:08:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ronak_saini_60abc1413f4e7/how-to-get-unix-timestamp-in-javascript-seconds-vs-milliseconds-5a5i"
  },
  "original_language": "en",
  "account": "JavaScript's handling of time differs from the standard Unix timestamp format, which uses seconds rather than milliseconds. Here's a clear guide on managing both formats effectively.\n\nTo obtain the current time in JavaScript, the Date.now() method defaults to providing the timestamp in milliseconds. This can be seen by logging the following code snippet to the console:\n\nconst timestampMs = Date.now();\nconsole.log(timestampMs);\n\nThe output will display the current time in milliseconds, such as 1726053000000.\n\nWhen it comes to standard Unix timestamps, they are seconds-based. Thus, to convert the JavaScript timestamp into the traditional Unix seconds format, you simply need to divide the millisecond value by 1000 and then apply Math.floor() to round down to the nearest whole number:\n\nconst timestampSec = Math.floor(Date.now() / 1000);\nconsole.log(timestampSec);\n\nThis will output the current time in Unix seconds, like 1726053000.\n\nIf you have a Unix timestamp expressed in seconds and need to convert it back into a JavaScript Date object, you must first multiply the timestamp by 1000. This will then be passed to the new Date() constructor to create the corresponding date object. Here's how you would do it:\n\nconst unixTimestamp = 1726053000;\nconst date = new Date(unixTimestamp * 1000);\nconsole.log(date.toISOString());\n\nThis will generate an ISO 8601 formatted string representing the date and time, such as \"2024-06-15T13:00:00.000Z.\"\n\nFor those who require a convenient tool to convert timestamps or explore timezones online, a quick-to-use web application has been developed for this purpose. It allows for instant conversions and timezone testing, providing a seamless experience at timestampeasy.com.",
  "summary": "Working with dates and timestamps in JavaScript can be slightly confusing because JS handles time in milliseconds, whereas standard Unix timestamps use seconds. Here is a quick reference guide to handle both correctly. Get Current Timestamp in Milliseconds By default, JavaScript's Date.now() returns the current timestamp in milliseconds:const timestampMs = Date.now(); console.log(timestampMs); //…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}