How-to Guide 5 min read

How to Convert a Date to a Unix Timestamp (Avoid the 5:30 Hour Error)

Turn a date and time into a Unix timestamp in seconds or milliseconds, and see why results are often off by your time zone offset, such as 5:30 hours in India.

convert date to unix timestampdate to epoch timedatetime to timestamp onlineunix timestamp ist to utcepoch time converter seconds milliseconds

The short answer

A Unix timestamp is the number of seconds (or milliseconds) since 1 January 1970 at 00:00:00 UTC. To convert a date, open the Unix Timestamp Converter, pick s or ms, type your date and time in the "Convert date → timestamp" box and click Convert. The one thing to get right is the time zone: the box reads your date in your device's local time, so in India 10:00 means 10:00 IST, not 10:00 UTC.

Why the time zone matters

A timestamp is a single moment in time. "21 October 2026, 10:00" is not a single moment until you say where. 10:00 in Mumbai happens five and a half hours before 10:00 in London's UTC.

These figures were calculated in code for that example date:

Date and timeUnix timestamp (seconds)
21 Oct 2026, 00:00 IST1792521000
21 Oct 2026, 10:00 IST1792557000
21 Oct 2026, 10:00 UTC1792576800

The gap between the second and third rows is 19800 seconds, which is exactly 5 hours 30 minutes. If you have ever seen a timestamp that was "off by 19800", this is why: the date was interpreted in IST when the system expected UTC, or the reverse.

Step by step in the Lazyblink converter

  • Open the Unix Timestamp Converter.
  • Choose the unit next to the timestamp box: ms (milliseconds, the default) or s (seconds). Pick this first, because the conversion uses whichever unit is selected.
  • Scroll to Convert date → timestamp and enter the date and time using the date picker.
  • Click Convert. The timestamp appears in the top box.
  • Check the result in the list underneath. It shows the same moment in ISO 8601 (which is always UTC and ends in Z), your local time, UTC, and several cities including Kolkata, New York, London, Dubai, Singapore and Tokyo.
  • If the UTC line shows the time you intended, the timestamp is right. If the Kolkata line shows it instead, the timestamp represents Indian time.

    One thing to watch: the pre-filled date

    When the page loads, the date box is filled with the current time in UTC, but the converter reads that box as local time. In India that means clicking Convert without editing gives a timestamp about five and a half hours in the past. Use the Use current time link above the timestamp box when you want "now", and always type your own value in the date box for anything else.

    How to convert a date that is in UTC (from India)

    Many APIs, log files and databases store times in UTC. If you are in India and need the timestamp for 10:00 UTC:

  • Enter the equivalent IST time, which is 15:30 on the same date, and convert. Or:
  • Enter 10:00, convert, and add 19800 to the result in seconds (19800000 in milliseconds).
  • Then check that the UTC row reads 10:00:00. The second method also works for any other zone if you know its offset from UTC, but remember that many countries change their offset for daylight saving time during the year. India does not.

    Seconds or milliseconds?

    UnitDigits todayTypical users
    Seconds10Unix and Linux tools, PHP, Python's time.time, most SQL databases, JWT exp and iat fields
    Milliseconds13JavaScript Date.now, Java System.currentTimeMillis, many browser and web APIs

    Mixing them up is the second most common mistake. A seconds value read as milliseconds lands in January 1970; a milliseconds value read as seconds lands tens of thousands of years in the future. If you see either, switch the unit. Our guide to Unix timestamps covers this and the year 2038 problem in more detail.

    Doing it in code

    The converter is useful for checking one value. In code, the same rules apply:

    • JavaScript: Math.floor(new Date('2026-10-21T10:00:00Z').getTime() / 1000) gives seconds for 10:00 UTC. Without the Z, JavaScript reads a date-time string as local time, which is exactly the 5:30 trap described above.
    • Python: int(datetime(2026, 10, 21, 10, 0, tzinfo=timezone.utc).timestamp()) gives 1792576800. A datetime without tzinfo is treated as local time.
    • Linux shell: date -u -d '2026-10-21 10:00' +%s treats the input as UTC because of -u.
    • Spreadsheets: Excel and Google Sheets store dates as days, not seconds. A common formula is (A1 - DATE(1970,1,1)) * 86400, which treats the cell as UTC, so adjust for your offset if the cell holds local time.

    Including an explicit time zone, such as Z or +05:30, is the single best habit for avoiding off-by-offset bugs.

    Troubleshooting

    My timestamp is 19800 too high or too low

    You mixed IST and UTC. Decide which zone your date is in, then add or subtract 19800 seconds accordingly.

    My date shows as 1970

    You are reading a seconds value as milliseconds. Switch the unit to s.

    The relative time says "from now" for a past date

    The timestamp is in the future, usually because the date was in a zone behind yours or the year was mistyped. Check the ISO line.

    The result changes between colleagues

    The date box uses each person's device time zone. Two people in different countries typing the same wall-clock time will get different timestamps. Agree on UTC and check the UTC line.

    Summary

    • A Unix timestamp counts from 1 January 1970, 00:00:00 UTC.
    • The converter reads the date you type in your device's local time zone.
    • In India, 10:00 local and 10:00 UTC differ by 19800 seconds.
    • Choose seconds or milliseconds before converting.
    • Confirm the result on the UTC line before you use it.

    If you need to convert a time between cities rather than to a number, convert to UTC first and then read the city you need from the same list.

    Frequently asked questions

    How do I convert a date to a Unix timestamp?

    Count the seconds between 1 January 1970 00:00:00 UTC and your date. In practice, enter the date and time in a timestamp converter, choose seconds or milliseconds, and convert. Make sure you know which time zone the date is in.

    Why is my Unix timestamp off by 19800 seconds?

    19800 seconds is 5 hours 30 minutes, the IST offset from UTC. Your date was read as Indian time when you meant UTC, or the other way round. Add 19800 to go from 10:00 IST to 10:00 UTC, or subtract it to go back.

    Is a Unix timestamp in seconds or milliseconds?

    Both exist. Most Unix tools, databases and APIs use seconds, which is currently a 10-digit number. JavaScript Date.now and many web APIs use milliseconds, a 13-digit number. Divide by 1000 to go from milliseconds to seconds.

    Which time zone does the Lazyblink converter use for the date I enter?

    The date and time box is read in your device's local time zone. On a phone or laptop set to India, a value you type is treated as IST, and the converter shows the result in UTC and several other zones so you can check it.

    Try this tool on Lazyblink

    Put this guide into practice with our free online tool — no signup required.

    Open tool