Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
EN – Language: English
Blog

How to Convert Time to a Unix Timestamp In Seconds, Any Time Zone

How to convert time to a Unix timestamp in seconds or milliseconds: browser, terminal, Excel, Python and JavaScript, with time zones done right.

By Daniyal Subhani 11 min read

Convert Time to a Unix Timestamp: The Short Answer

You have a date and a time, and some system wants a single number instead. To convert time to a Unix timestamp, count the seconds between your moment and midnight on 1 January 1970 in UTC. That count is the timestamp. For 10:00 UTC on 17 November 2026, the answer is 1794909600.

Diagram: pick a date and time zone, move it to UTC, then count the seconds since 1 January 1970
Three moves: pick the time, shift it to UTC, then count the seconds.

The fastest way is our free Unix Timestamp Converter. Type a date, choose the time zone and copy the result in seconds or milliseconds. It runs in your browser, so nothing you type leaves your computer.

As mentioned above, the most difficult part of this conversion is time zone. Once you’ve figured out the time zone, the rest of the conversion is very easy to do.

What a Unix Timestamp Really Counts

A Unix timestamp is a running count of seconds. The count started at 00:00:00 UTC on 1 January 1970, a moment people call the Unix epoch. One day later the count read 86400, because a day holds 86,400 seconds.

The format comes from the Unix operating system, and the POSIX standard still defines it today. Servers, databases, APIs and log files all use it, because one plain number is easy to store, sort and compare.

Seconds or Milliseconds?

Most systems count seconds with 10 digits. In JavaScript and most web interfaces this is misunderstood to mean they use 13 digit millisecond counts. Because of this difference the representation of the same point in time may be very different in the two systems.

One moment, three common formats
FormatValue for 17 Nov 2026, 10:00 UTCWhere you see it
Seconds1794909600Linux, PHP, Python, MySQL, most APIs
Milliseconds1794909600000JavaScript, Java, many web APIs
ISO 86012026-11-17T10:00:00ZJSON files, logs, human-readable APIs

A quick rule helps here. If a number has 10 digits, it almost certainly counts seconds. If it has 13, it counts milliseconds. Divide by 1000 to move from milliseconds to seconds.

What a Timestamp Ignores

Timestamps generated by the Unix system do not contain information about time zones or daylight saving time. They also do not contain leap seconds. As a result, the number of seconds in the whole day is always 86,400.

Time Zones Decide the Answer

This is where most users run into problems. Timestamps are always expressed in UTC. Time as shown by a user’s clock is not. Therefore, to perform any conversion using a given date you must first determine which time zone the date is in.

Take 10:00 on 17 November 2026 as an example. That wall-clock time happens at a different instant in each city. As a result, it gives a different timestamp in each one.

10:00 on 17 Nov 2026 in three places
Time zoneOffset from UTCUnix timestamp
London (UTC)+00:001794909600
Karachi (PKT)+05:001794891600
New York (EST)−05:001794927600

The gaps are exactly 18,000 seconds, which is five hours. In other words, the wrong zone never gives an error. It just gives a number that looks fine and is quietly wrong.

To be safe, when converting a date to a timestamp always include the time zone of the date. If no time zone is included with the date prior to conversion, find out in what location the date was created.

Daylight saving time is another complication. New York is located at -05:00 in the winter and -04:00 in the summer. Tools that account for named time zones will account for this change for you. Using a fixed offset of -05:00 will not.

Convert in Your Browser

For individual dates or a few dates a web tool would be simplest to use. This is the case with our converter as well.

Step 1: Enter the Date and Time

Open the Unix Timestamp Converter and type your date in the box. The tool accepts plain dates, ISO strings and most common formats.

Step 2: Choose the Time Zone

Select the time zone your date is in from the list. If you leave it set to the time zone your device is currently set to, the time may have been copied incorrectly.

Unix Timestamp Converter with a date typed in and the time zone list highlighted
Enter the date and then select the time zone.

Step 3: Copy Seconds or Milliseconds

The site instantly generates the result in various formats including seconds and milliseconds. Coppy the appropriate format for your system. The website also displays the current Unix timestamp.

Converter results showing the same moment in Unix seconds, milliseconds and ISO 8601
Show me the format of time most convenient to you.

Convert Time to a Unix Timestamp in Code

When you work with many dates, a line of code beats any web page. Each example below converts 10:00 UTC on 17 November 2026 and prints 1794909600.

Terminal (Linux and macOS)

On a Linux system the date command used with GNU date will print the date for you. On macOS you will have to use the format string first, like this ‘WWWW’.

# Linux (GNU date)
date -u -d "2026-11-17 10:00:00" +%s

# macOS (BSD date)
date -u -j -f "%Y-%m-%d %H:%M:%S" "2026-11-17 10:00:00" +%s

# The current Unix timestamp, anywhere
date +%s

Python

Python is safest when you attach a time zone to the date. A date without one is read as local time, which is a classic source of bugs. The Python datetime docs explain this rule in full.

from datetime import datetime, timezone

moment = datetime(2026, 11, 17, 10, 0, tzinfo=timezone.utc)
print(int(moment.timestamp()))  # 1794909600

JavaScript

JavaScript counts in milliseconds and numbers months from zero. So November is month 10, and you divide by 1000 at the end. MDN's Date.UTC page covers the details.

const ms = Date.UTC(2026, 10, 17, 10, 0); // month 10 = November
console.log(Math.floor(ms / 1000));      // 1794909600

// The current Unix timestamp in seconds
Math.floor(Date.now() / 1000);

PHP, SQL and PowerShell

// PHP
echo strtotime('2026-11-17 10:00:00 UTC'); // 1794909600

-- MySQL (uses the session time zone)
SELECT UNIX_TIMESTAMP('2026-11-17 10:00:00');

# PowerShell
[DateTimeOffset]::new(2026,11,17,10,0,0,[TimeSpan]::Zero).ToUnixTimeSeconds()

Pay attention to the comment in MySQL. UNIX_TIMESTAMP gets the date in the session time zone. To convert a time stored in UTC to this format, use the command SET time_zone = '+00:00' first.

Excel and Google Sheets

Spreadsheets store dates as day counts, not seconds. Excel's day 1 is 1 January 1900, while Unix starts in 1970. So the formula subtracts the epoch and then multiplies by the seconds in a day.

=(A2 - DATE(1970,1,1)) * 86400

Put your date in A2 and this formula in B2. Then format B2 as a plain number with no decimals. The same formula works in Google Sheets without any change.

One warning applies, though. The sheet treats your date as UTC. If A2 holds a local time, subtract the offset first. For Karachi, that means =(A2 - 5/24 - DATE(1970,1,1)) * 86400.

Spreadsheet formulas for common jobs
JobFormulaNotes
UTC date to seconds=(A2-DATE(1970,1,1))*86400Format the cell as a number
UTC date to milliseconds=(A2-DATE(1970,1,1))*86400000Gives 13 digits
Seconds back to a date=A2/86400+DATE(1970,1,1)Format the cell as a date and time
Local time (UTC+5) to seconds=(A2-5/24-DATE(1970,1,1))*86400Change 5 to your own offset

Convert a Unix Timestamp Back to a Date

Going the other way is just as common. Maybe a log file shows 1794909600 and you want to know when that was. Paste the number into the converter, and it shows the date in UTC and in your chosen zone.

In code, the reverse step mirrors the forward one. Python uses datetime.fromtimestamp(ts, timezone.utc), and JavaScript uses new Date(ts * 1000). Always pass a zone, or the result lands in the local time of whatever machine runs the code.

Discord dates work similarly to the ones here. The message ’’’t:1794909600’’’ shows the time in that message’s timestamp in each user’s time zone.

A Real Case: The Sale That Started Five Hours Late

A small online shop in Karachi planned a flash sale for 10:00 on a Friday. The developer typed the start time into a script and saved the result as a Unix timestamp. The script ran on a cloud server set to UTC.

The server read 10:00 as UTC, which is 15:00 in Karachi. So the sale opened five hours late, after a morning of social posts promising a 10:00 start. Customers arrived, saw full prices and left.

The fix took one line. The developer attached the Asia/Karachi zone to the date before converting, and the timestamp dropped by exactly 18,000 seconds. After that, the team added a habit: every scheduled time in their notes now carries its zone, like 10:00 PKT.

What went wrong, in numbers
StepWrong runFixed run
Time typedFriday 10:00Friday 10:00 Asia/Karachi
Zone usedUTC (server default)UTC+05:00
Sale opened (Karachi time)15:0010:00

Common Mistakes and How to Spot Them

Most broken conversions come from a short list of slips. Check these first whenever a timestamp looks odd.

  • Wrong zone: the result is off by a whole number of hours. Compare it with UTC to find the gap.
  • Milliseconds read as seconds: the date lands tens of thousands of years in the future.
  • Seconds read as milliseconds: the date lands in January 1970.
  • JavaScript month off by one: the date is a month later than you meant.
  • Daylight saving with a fixed offset: summer dates come out one hour wrong.

One more limit is worth knowing about. Old systems that store the timestamp in a signed 32-bit number stop at 2147483647. That moment is 03:14:07 UTC on 19 January 2038, and people call it the year 2038 problem. Modern systems use 64 bits, so they run fine far past it.

In short: pick the zone, shift to UTC, count the seconds and check the digit count. Do that each time, and your timestamps will match on every server, sheet and screen.

Questions and Answers

How do I get the Unix timestamp for a given date and time?

Count the seconds from 00:00 UTC on 1 January 1970 to your moment. A converter does it for you: enter the date, pick the time zone and copy the number.

What is the current Unix timestamp?

It’s changing every second. The number at the top of the page and the command date +%s in terminal are both showing the live number.

What is the Unix epoch?

This is referred to as the epoch. It’s the start of the countdown. 00:00:00 1 January 1970 UTC. That particular timestamp is 0.

Is a Unix timestamp in UTC?

Yes. The number always counts from a UTC starting point, so it has no time zone of its own. Zones only matter when you turn it into a clock time.

Why is my time stamp so far away from the real time?

Most likely the time stamp was read in the wrong time zone. The difference in hours from the real time reflects the difference between the time zone of the real time and the time zone of the web service.

How do I tell seconds from milliseconds?

Count the digits. Ten digits means seconds, and thirteen digits means milliseconds for any date in our lifetime.

How do I convert milliseconds to seconds?

Divide by 1000 and drop the decimals. For example, 1794909600000 becomes 1794909600.

How do I get the Unix timestamp of a given date in Excel?

Use =(A2-DATE(1970,1,1))*86400 with your UTC date in A2. Then format the result as a plain number.

Does this function work in Google Sheets as well?

Yes. Google Sheets uses the same date system for this sum, so the formula works without changes.

How do I get a Unix timestamp in JavaScript?

To get the timestamp of the current date use Math.floor(Date.now()/1000). To get of a specific timestamp of a future or past date use Date.UTC(year, month, day).

How do I get a Unix timestamp in Python?

Create a datetime object with time zone set to UTC and then call timestamp().

Does daylight saving change the timestamp?

No, the number itself never jumps. Daylight saving only changes which clock time matches a timestamp, so use named zones, not fixed offsets.

Can a Unix timestamp be negative?

Yes. Dates before 1970 give negative numbers. For example, the last second of 1969 is −1.

What is the year 2038 problem?

Signed 32-bit storage tops out at 2147483647, which is 19 January 2038. Systems using 64 bits avoid it completely.

Do Unix timestamps count leap seconds?

No. Every day counts as exactly 86,400 seconds, which keeps the arithmetic simple.

How do I change a Unix timestamp to a date?

You can use the converter or use datetime.fromtimestamp(ts, timezone.utc) in python. In javascript use new Date(ts * 1000).

Why does MySQL give a different answer?

UNIX_TIMESTAMP uses the time zone of the session. Set your session to +00:00 if the time zones of the dates you stored is set to UTC.

How do Discord timestamps work?

Write <t:TIMESTAMP:F> in a message. Discord then shows each reader that moment in their own local time.

Is the converter free and private?

No sign in is required and it runs in your browser so no data is sent to the servers.

Can I convert many dates at once?

Yes. To convert a whole column in a spreadsheet use the function in one of the cells in that column.

Video guide

Converting a Date to a Unix Timestamp, Step by Step

This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.

Convert Your Date Now

Enter the date of your choice, select its time zone and copy the timestamp. This app is free to use and does not collect data.

Prefer Denwix on GoogleReview Denwix on Google