ThisCalculator

Everyday

UTC to IST Converter JS: Code & Formula

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

This page explains how to convert UTC (Coordinated Universal Time) to IST (Indian Standard Time) in JavaScript. You enter a UTC time (as a Date object, timestamp, or string) and the code returns the equivalent IST time, which is UTC+5:30. The conversion is straightforward once you understand how JavaScript handles time zones.

Formula

IST is always 5 hours and 30 minutes ahead of UTC. So the basic formula is:

IST time = UTC time + 5.5 hours

In minutes: IST minutes = UTC minutes + 330. If the result is 1440 or more, subtract 1440 and add one day to the date.

Variables:

  • UTC time – the time in UTC, expressed as hours and minutes (e.g., 12:00).
  • IST time – the corresponding time in India, also in hours and minutes.
  • 330 – the offset in minutes (5 hours × 60 + 30 minutes).

Worked Example

Using the default values from the calculator: UTC date = 2024-01-15, UTC time = 12:00.

  1. Convert 12:00 to minutes: 12 × 60 + 0 = 720 minutes.
  2. Add the IST offset: 720 + 330 = 1050 minutes.
  3. 1050 is less than 1440, so the date stays the same.
  4. Convert 1050 minutes back to HH:MM: 1050 ÷ 60 = 17 hours remainder 30 minutes → 17:30.

So 12:00 UTC on 2024-01-15 is 17:30 IST on the same day.

How JavaScript Date Handles Time Zones

JavaScript’s Date object stores a timestamp (milliseconds since 1970-01-01 UTC) and provides methods that work in the local time zone of the browser or server. When you call getHours(), it returns the hour in your local time zone, not UTC. To work with UTC explicitly, use the getUTCHours(), getUTCMinutes(), etc., or use toISOString() which always returns UTC.

For conversion, you can either:

  • Extract the UTC components and add 330 minutes manually.
  • Create a new Date using Date.UTC() with the UTC components, then add 330 minutes and use getUTCHours() to display.

Simple JavaScript Function for UTC to IST

Here is a clean function that converts a UTC Date object to an IST-formatted string:

function utcToIst(utcDate) {
  // Create a new Date object to avoid mutating the original
  const istDate = new Date(utcDate.getTime() + (330 * 60000));
  // Format as HH:MM:SS using UTC getters (since we shifted the timestamp)
  return istDate.toISOString().slice(11, 19);
}

// Example: 2024-01-15 12:00 UTC
const utc = new Date('2024-01-15T12:00:00Z');
console.log(utcToIst(utc)); // "17:30:00"

This works because adding 330 minutes to the timestamp shifts the UTC time to IST, and toISOString() always returns that shifted time in UTC format, which now represents IST.

Handling Date Boundaries and Edge Cases

When the UTC time is late in the day, adding 330 minutes can push the result past midnight. For example, 20:00 UTC becomes 01:30 IST the next day. Your code must handle the date rollover correctly. The calculator above does this by checking if the minute sum exceeds 1439 and adding a day to the date.

Also be aware of daylight saving time – India does not observe DST, so the offset is constant year-round. However, if you are converting from a UTC time that is itself derived from a location that uses DST, make sure you have the correct UTC time first. JavaScript’s Date automatically handles DST for local time, but when you parse strings like "2024-01-15T12:00:00Z", it treats them as UTC regardless of DST.

Common Mistakes and How to Avoid Them

  • Using local time methods – getHours() returns local time, not UTC. Always use getUTCHours() or shift the timestamp.
  • Forgetting the 30-minute offset – Some people use 5 hours instead of 5.5. Always use 330 minutes.
  • Not handling date rollover – When the result exceeds 24 hours, you must adjust the date. The formula above takes care of that.
  • Mutating the original Date – If you call setMinutes() on the original object, you change it permanently. Create a copy.

Alternatives to Manual Conversion

If you don’t want to write the conversion yourself, you can use libraries like moment-timezone or the modern Intl.DateTimeFormat with the timeZone option. For example:

new Intl.DateTimeFormat('en-IN', { timeZone: 'Asia/Kolkata', hour: '2-digit', minute: '2-digit' }).format(new Date());

This will format the current time in IST without manual arithmetic. However, for a simple, dependency-free conversion, the manual method shown above is reliable and easy to understand.

Frequently Asked Questions

What is the time difference between UTC and IST?

IST (Indian Standard Time) is UTC+5:30, meaning it is 5 hours and 30 minutes ahead of UTC. There is no daylight saving time in India, so this difference is constant all year.

How do I convert a UTC string like “2024-01-15T12:00:00Z” to IST in JavaScript?

You can parse the string with new Date('2024-01-15T12:00:00Z') to get a Date object, then add 330 minutes and format using toISOString() or getUTCHours()/getUTCMinutes(). The function in the article does exactly that.

Why does my conversion show the wrong hour?

Most likely because you used local time methods like getHours() instead of UTC methods. Remember that getHours() returns the time in your browser’s time zone, not UTC. Always use getUTCHours() or work with the timestamp directly.

Does JavaScript automatically handle IST for me?

No, JavaScript’s Date object only knows UTC and the local time zone of the environment. To get IST, you must either add the offset manually or use Intl.DateTimeFormat with the timeZone option set to ‘Asia/Kolkata’.

Can I use this conversion for server-side Node.js?

Yes, the same code works in Node.js. The Date object and Intl are available server-side. Just be aware that the server’s local time zone may differ from the client’s, but the conversion logic is identical.

What about converting IST back to UTC?

Just subtract 330 minutes from the IST time. For example, 17:30 IST minus 330 minutes gives 12:00 UTC. The same date rollover logic applies in reverse.

Related

Formula used
in t | UTC time (HH:MM) | - | 12:00 | 0
in d | UTC date (YYYY-MM-DD) | - | 2024-01-15 | 0
out ist | IST time (HH:MM) | - | (timeToMinutes(t) + 330) % 1440 | 0
out ist_date | IST date | - | addDays(d, floor((timeToMinutes(t) + 330) / 1440)) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.