Urgent.News

What's breaking now, across thousands of outlets.

Tech

Unix Timestamp Explained: What Epoch Time Is and How to Convert It

If you've worked with APIs, databases, logs, authentication systems or backend applications, you've probably encountered a Unix timestamp. You may see values such as: 1725369600 At first glance, it looks like a random number. It isn't. A Unix timestamp represents a specific point in time and is widely used by computers to store and exchange dates. In this guide, we'll explain what a Unix…

Unix timestamps are numeric values representing specific moments in time. They indicate the number of seconds that have passed since a specific starting point, known as the Unix epoch, which is January 1, 1970 at 00:00:00 UTC. This single numeric value makes it simple for computers to store, compare, and transmit dates without the need for various human-readable date formats.

Developers frequently use Unix timestamps in APIs, databases, application logs, JWT tokens, authentication systems, cloud applications, cron jobs, scheduling, file metadata, and distributed systems. Comparing two timestamps is straightforward, as a larger timestamp signifies a later point in time. For instance, comparing timestamp A and timestamp B, where timestamp A is less than timestamp B, means that A occurred before B.

There is a common mistake when dealing with Unix timestamps: distinguishing between seconds and milliseconds. A timestamp in seconds may appear as 1757894400, while a timestamp in milliseconds appears as 1757894400000. The latter is 1,000 times larger because there are 1,000 milliseconds in a single second. In JavaScript, the Date.now() method provides timestamps in milliseconds, and Math.floor(Date.now() / 1000) converts it to seconds.

JavaScript's Date object can be utilized to work with Unix time. To get the current timestamp in milliseconds, use Date.now(). To convert a Unix timestamp back into a JavaScript Date object, multiply it by 1000. Conversely, Python's time module facilitates Unix timestamp operations. To get the current Unix timestamp in Python, import time and use int(time.time()).

To convert a timestamp into a readable UTC date, import datetime and timezone from the datetime module, then use datetime.fromtimestamp(timestamp, tz=timezone.utc).

Linux systems make it easy to work with Unix timestamps from the command line. To get the current timestamp, use the command date +%s. To convert a Unix timestamp into a readable date, use date -d @1757894400. When working with APIs or logs, always verify if the application expects seconds or milliseconds to avoid incorrect date conversions.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

When the Leased Laptops Went Back, the Data Went With Them

Three hundred and forty laptops came off a three year lease last spring. A logistics firm collected them over four days, signed a manifest, and returned them to the lessor.

  • 340 leased laptops lacked proper data sanitization
  • 28 devices never returned, posing security risk
  • Company updated procedures for in-house data sanitization

The secret was masked until we base64 encoded it

An engineer scrolling a failed build on a Monday afternoon found our registry deploy token sitting in the log in plain sight. Not the whole log.

  • Developer found registry deploy token in plain text in build log
  • CI system echoed every command executed with set -x
  • Masking and lint rule implemented to prevent future secret leaks

From 1,256ms to 96ms: Fixing INP in a Massive React Dropdown

The Scenario In Subito's design system, we rely heavily on a custom MultiSelect component. We use it across our marketplace as a standard checkbox-style filter: you search, tick a few boxes, and hit…

  • Subito's MultiSelect component negatively impacts mobile performance with 1,256ms INP
  • Implemented virtualization technique to render only visible items plus buffer
  • Custom useVirtualScroll hook tracks scroll position, renders ~13 necessary rows

Every Release Note Is a Lesson Somebody Paid For

There is a free, expertly written, continuously updated course on almost every tool you use, and hardly anyone opens it. It is the release notes. Think about what goes into one.

  • Release notes contain concise descriptions of changes and deprecations.
  • Review release notes monthly for essential tools like language runtime.
  • Reading upgrade guides explains previous design flaws and prepares for changes.

More from Tuesday 15 September →