<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sam</title>
    <description>The latest articles on DEV Community by Sam (@sam_ybs).</description>
    <link>https://dev.to/sam_ybs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4112648%2F625e69e5-269f-461f-8685-e1cdcb5285d5.png</url>
      <title>DEV Community: Sam</title>
      <link>https://dev.to/sam_ybs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sam_ybs"/>
    <language>en</language>
    <item>
      <title>Unix Timestamps Explained: A Practical Guide for Developers</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Thu, 10 Sep 2026 20:32:00 +0000</pubDate>
      <link>https://dev.to/sam_ybs/unix-timestamps-explained-a-practical-guide-for-developers-cdd</link>
      <guid>https://dev.to/sam_ybs/unix-timestamps-explained-a-practical-guide-for-developers-cdd</guid>
      <description>&lt;p&gt;If you work with APIs, logs, databases, authentication tokens, or scheduled jobs, you have probably seen numbers like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1789056000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That number can represent a date and time using a &lt;strong&gt;Unix timestamp&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Unix Timestamp?
&lt;/h2&gt;

&lt;p&gt;A Unix timestamp represents the number of seconds that have passed since:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;January 1, 1970 00:00:00 UTC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This point in time is known as the &lt;strong&gt;Unix Epoch&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;represents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1970-01-01 00:00:00 UTC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As time passes, the Unix timestamp increases.&lt;/p&gt;




&lt;h2&gt;
  
  
  Seconds vs Milliseconds
&lt;/h2&gt;

&lt;p&gt;One common source of bugs is confusing &lt;strong&gt;seconds&lt;/strong&gt; with &lt;strong&gt;milliseconds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A Unix timestamp in seconds may look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1789056000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same type of value in milliseconds may look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1789056000000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript's &lt;code&gt;Date&lt;/code&gt; API normally works with &lt;strong&gt;milliseconds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1789056000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We multiply the timestamp by &lt;code&gt;1000&lt;/code&gt; because:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 second = 1000 milliseconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Get the Current Unix Timestamp in JavaScript
&lt;/h2&gt;

&lt;p&gt;Getting the current Unix timestamp is simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Date.now()&lt;/code&gt; returns the current time in milliseconds.&lt;/p&gt;

&lt;p&gt;Dividing it by &lt;code&gt;1000&lt;/code&gt; converts it to seconds.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Math.floor()&lt;/code&gt; removes the decimal portion.&lt;/p&gt;




&lt;h2&gt;
  
  
  Convert a JavaScript Date to Unix Time
&lt;/h2&gt;

&lt;p&gt;You can also convert any JavaScript &lt;code&gt;Date&lt;/code&gt; object into a Unix timestamp.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2026-09-11T10:00:00Z&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;getTime()&lt;/code&gt; returns milliseconds, so we divide the result by &lt;code&gt;1000&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Convert Unix Time Back to a Date
&lt;/h2&gt;

&lt;p&gt;You can convert a Unix timestamp back into a readable JavaScript date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1789056000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toISOString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is especially useful when debugging API responses, database records, or logs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where Are Unix Timestamps Used?
&lt;/h2&gt;

&lt;p&gt;Unix timestamps appear in many parts of software development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;REST APIs&lt;/li&gt;
&lt;li&gt;JWT tokens&lt;/li&gt;
&lt;li&gt;Database records&lt;/li&gt;
&lt;li&gt;Server logs&lt;/li&gt;
&lt;li&gt;Scheduled jobs&lt;/li&gt;
&lt;li&gt;Caching systems&lt;/li&gt;
&lt;li&gt;Authentication sessions&lt;/li&gt;
&lt;li&gt;Analytics events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, a JWT payload might contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"iat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1789056000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1789059600&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;iat&lt;/code&gt;&lt;/strong&gt; means &lt;strong&gt;Issued At&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;exp&lt;/code&gt;&lt;/strong&gt; means &lt;strong&gt;Expiration Time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These values make it easy for applications to determine when a token was created and when it should expire.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Are Unix Timestamps Useful?
&lt;/h2&gt;

&lt;p&gt;One major advantage of Unix timestamps is that they represent a &lt;strong&gt;specific point in time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, a value like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;11 September 2026, 3:30 PM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can become confusing because the timezone is unclear.&lt;/p&gt;

&lt;p&gt;But a Unix timestamp represents the same moment regardless of where the user is located.&lt;/p&gt;

&lt;p&gt;Your application can then convert that timestamp into the user's local timezone when displaying it.&lt;/p&gt;

&lt;p&gt;This makes Unix timestamps especially useful for:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;APIs, distributed applications, databases, authentication systems, and server logs.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  A Small Tool I Built
&lt;/h2&gt;

&lt;p&gt;While working with timestamps, I often needed a quick way to convert between Unix timestamps and readable dates.&lt;/p&gt;

&lt;p&gt;Opening the browser console every time worked, but it wasn't very convenient.&lt;/p&gt;

&lt;p&gt;So I built a &lt;strong&gt;Unix Timestamp Converter&lt;/strong&gt; as part of a project I'm working on called &lt;strong&gt;YBS — Your Browser Suite&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://ybstools.com/tools/unix-timestamp-converter/" rel="noopener noreferrer"&gt;Try the Unix Timestamp Converter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It lets you quickly convert between Unix timestamps and readable date/time values directly in your browser.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is YBS?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ybstools.com/" rel="noopener noreferrer"&gt;YBS — Your Browser Suite&lt;/a&gt; is a collection of small browser-based utilities for common developer tasks.&lt;/p&gt;

&lt;p&gt;It currently includes tools for things such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON formatting&lt;/li&gt;
&lt;li&gt;Regex testing&lt;/li&gt;
&lt;li&gt;Cron expressions&lt;/li&gt;
&lt;li&gt;JWT decoding&lt;/li&gt;
&lt;li&gt;Diff checking&lt;/li&gt;
&lt;li&gt;Base64 encoding&lt;/li&gt;
&lt;li&gt;Unix timestamp conversion&lt;/li&gt;
&lt;li&gt;YAML viewing&lt;/li&gt;
&lt;li&gt;Word and character counting&lt;/li&gt;
&lt;li&gt;QR code generation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No signup is required.&lt;/p&gt;

&lt;p&gt;I'm continuing to improve the project and add useful tools over time.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Should I Build Next?
&lt;/h2&gt;

&lt;p&gt;I'm curious what other developers repeatedly search for while coding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What small developer tool do you wish you had available instantly in your browser?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let me know in the comments. 👇&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
