Learn how to add the time across spreadsheets, code, SQL, and automation. Clear steps, examples, and best practices to avoid DST and time zone mistakes.
Last Verified: September 2026
Quick Answer: To add the time reliably, convert both the base time and the duration to a single unit (usually seconds), perform the addition, handle overflow (minutes > 59, hours > 23) and date rollovers, then format the result. Keep internal math in UTC, apply time zones only at input/output, and use proven libraries for DST and calendar logic.
“Add the time” means increasing a time value by a duration. It can be as simple as adding 30 minutes to 2:45 PM or as precise as adding ISO 8601 durations to timestamps across time zones. There are two core ideas:
Precision, time zones, DST, and calendar rules affect results. The safest approach is to convert to a single unit (seconds), add, then format.
Use this approach anywhere you need to add the time without surprises.
Tip from experience: Avoid “string math” like splitting on colons and adding textually. Parse strings into real time types first, then add.
Spreadsheet times are fractions of a day. That’s the key model:
Common patterns
Notes from practice
Use reliable libraries for serious time math. Keep data in UTC internally and convert to the user’s zone only for display.
Native Date (UTC math)
const base = new Date('2026-02-10T14:00:00Z');
const minutes = 90;
const result = new Date(base.getTime() + minutes * 60 * 1000);
// result.toISOString() => '2026-02-10T15:30:00.000Z'
date-fns (lightweight, composable)
import { addMinutes, addHours } from 'date-fns';
const base = new Date('2026-02-10T14:00:00Z');
const result = addMinutes(base, 90);
Luxon (time zone aware)
import { DateTime, Duration } from 'luxon';
const base = DateTime.fromISO('2026-02-10T14:00:00Z');
const result = base.plus(Duration.fromObject({ minutes: 90 }));
// Display in a user zone when needed
const shown = result.setZone('America/New_York').toFormat('yyyy-LL-dd HH:mm');
Practical notes we’ve verified
Python’s datetime and timedelta handle duration math well. For time zones, use zoneinfo (Python 3.9+).
Basic timedelta
from datetime import datetime, timedelta
base = datetime.fromisoformat('2026-02-10T14:00:00+00:00')
result = base + timedelta(minutes=90)
# '2026-02-10T15:30:00+00:00'
Time zone aware with zoneinfo
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
base = datetime(2026, 2, 10, 14, 0, tzinfo=ZoneInfo('UTC'))
result_utc = base + timedelta(hours=5)
result_local = result_utc.astimezone(ZoneInfo('America/New_York'))
Pandas series addition
import pandas as pd
s = pd.Series(pd.to_datetime(['2026-02-10 14:00Z', '2026-02-10 14:05Z']))
s_plus_30 = s + pd.Timedelta(minutes=30)
Hands-on tip
Use native interval functions for clarity and correctness, and store UTC in the database.
MySQL / MariaDB
SELECT DATE_ADD('2026-02-10 14:00:00', INTERVAL 90 MINUTE);
-- or
SELECT TIMESTAMP('2026-02-10 14:00:00') + INTERVAL 90 MINUTE;
PostgreSQL
SELECT TIMESTAMP '2026-02-10 14:00:00' + INTERVAL '90 minutes';
SQL Server
SELECT DATEADD(MINUTE, 90, '2026-02-10T14:00:00');
BigQuery
SELECT TIMESTAMP_ADD(TIMESTAMP '2026-02-10 14:00:00+00', INTERVAL 90 MINUTE);
Practical guidance
Bash (GNU date)
base='2026-02-10 14:00:00 UTC'
result=$(date -u -d "$base + 90 minutes" +%Y-%m-%dT%H:%M:%SZ)
echo "$result"
Note: macOS/BSD date differs in flags; for portability, consider Python.
PowerShell
$base = Get-Date '2026-02-10T14:00:00Z'
$result = $base.AddMinutes(90)
$result.ToString('o') # ISO 8601 round-trip
For APIs, the most robust pattern is ISO 8601 timestamps and durations.
Example payload
{
"start": "2026-02-10T14:00:00Z",
"duration": "PT90M",
"end": "2026-02-10T15:30:00Z"
}
Implementation notes we’ve confirmed
| Environment | Primary Function/Type | Time Zone Aware | DST-Safe Approach | Notes |
|---|---|---|---|---|
| Excel/Sheets | TIME, DATE, serial days | Display-only | Compute as day fractions; avoid locale parsing | Use [h]:mm:ss for >24h totals |
| JavaScript | Date, date-fns, Luxon | With libraries | Compute in UTC; convert with IANA zones | Avoid ambiguous local strings |
| Python | datetime, timedelta, zoneinfo | Yes (zoneinfo) | Do arithmetic in aware UTC, then localize | Excellent stdlib support |
| MySQL/Postgres | DATE_ADD/INTERVAL | Limited in-engine | Store UTC; convert app-side | Use calendar functions for months |
| SQL Server | DATEADD | Limited in-engine | Store UTC; convert app-side | Be explicit with styles |
| BigQuery | TIMESTAMP_ADD | N/A (UTC) | Timestamps are UTC; cast to DATETIME with zone if needed |
What’s the safest way to add the time across time zones? Compute in UTC, add the duration, then convert to the target time zone for display using an IANA zone name (e.g., America/New_York). This avoids DST issues and ambiguous local times. Only parse local user input at the edge, immediately convert to UTC, and store that UTC value.
How do I add 90 minutes to 2:45 PM in Excel and show totals over 24 hours? Use =A2 + TIME(1,30,0) if A2 holds 2:45 PM. To show totals beyond 24 hours (like 27:15), set the cell’s custom format to [h]:mm:ss. Spreadsheet times are day fractions, so use TIME or N/1440 for reliable additions.
Should I store timestamps in UTC or local time? Store timestamps in UTC almost always. Convert to local time only for input and output. UTC storage simplifies arithmetic, avoids DST ambiguity, and makes cross-region systems predictable. Keep the user’s original time zone alongside the record for reproducibility when displaying later.
How do ISO 8601 durations work in APIs? ISO 8601 durations use a P…T… format, such as PT90M for 90 minutes or P1DT2H for 1 day 2 hours. Send and receive start timestamps (e.g., 2026-02-10T14:00:00Z) with durations, compute in UTC, and return the end timestamp. Validate time zones with IANA names.
What’s the difference between adding a duration and adding two times of day? Timestamp plus duration yields a new timestamp (a moment in time). Time-of-day plus time-of-day yields a duration (e.g., 10:20 + 3:50 = 14:10). You don’t get a valid moment unless you attach a date and zone, because clock times repeat daily and differ by region.
How do I handle adding months or years reliably? Use calendar-aware functions (e.g., ADD_MONTHS, dateutil.relativedelta, or equivalent). Month lengths vary and leap years exist, so fixed-day assumptions break. Define clear business rules for end-of-month behavior (e.g., Jan 31 + 1 month → Feb 29 or Feb 28 depending on year).
How do I avoid DST bugs when I add the time around the spring/fall changes? Do arithmetic in UTC. Local 02:xx may not exist in spring, and 01:xx may repeat in fall. Convert to the user’s IANA time zone for display only. Libraries that apply the IANA time zone database resolve these transitions correctly.
Is it okay to do time math with strings like “14:20” in code? No. Parse the string into a real time object or epoch first, then add. String concatenation or splitting on colons easily leads to carry errors, missing date rollovers, and DST mistakes. Typed operations enforce correct overflow and formatting.
To add the time accurately, normalize to a single unit, compute in UTC, and use calendar-aware functions and IANA zones when necessary. Test DST, month ends, and leap years. Document rounding. This approach scales from spreadsheets to APIs without surprises.
If you routinely add the time for scheduling, payroll, or analytics, standardize your team’s patterns and keep a small test suite of edge-case fixtures. It pays off the first time a DST or month-end issue would have bitten you.
A complete, expert guide to creating secure Wi‑Fi QR codes that just work on iPhone and Android, with best practices and a step‑by‑step workflow.
Learn how to convert 1 meter to feet with precise formulas, quick methods, and real-world examples. Includes best practices, common mistakes, comparison tables, FAQs, and expert tips for accurate length conversions.
| Clear semantics |
| Bash | date (GNU) | Via -u and TZ | Prefer UTC flags | BSD/macOS differ |
| PowerShell | DateTime.AddX | Via .Kind/offset | Use UTC internally | .NET formatting is rich |
How do I add minutes to the current time in JavaScript? Use milliseconds on the Date object or a library. Example: new Date(Date.now() + minutes * 60_000). For complex cases or time zones, use date-fns addMinutes or Luxon with an IANA zone, then format for display. Prefer ISO 8601 for serialization.
How do I sum work shifts in Google Sheets when totals exceed 24 hours? Sum the range normally and set the result cell to the custom format [h]:mm:ss. Without that format, Sheets/Excel wrap after 24 hours and display a misleading time-of-day. The [h] bracket tells the spreadsheet to continue counting hours beyond a single day.
What rounding rules should I use for payroll or billing? Pick a rule once and document it: round up (ceiling), down (floor), or to nearest increment (e.g., 6-minute or 15-minute blocks). Apply it consistently at the smallest event level to avoid cumulative surprises. Unit-test the rules with edge-case times.
How do I add the time in SQL when my app needs months added too? Use native interval support: INTERVAL '1 month' in PostgreSQL or DATE_ADD with MONTH in MySQL. For business calendars (skip weekends/holidays), do not rely on raw SQL addition alone; incorporate a calendar table or application logic to skip non-business days.
Why does 01:30 not exist on some days in my local time zone? During the spring DST transition, clocks jump forward and certain local times never occur (e.g., 02:00–02:59). If you try to interpret these times, libraries may roll forward or raise errors. Compute in UTC first, then convert to local time for display.
How do I represent durations and timestamps in JSON APIs? Use ISO 8601/RFC 3339 for timestamps (e.g., 2026-02-10T14:00:00Z) and ISO 8601 durations (e.g., PT45M). Return both the normalized inputs and computed outputs to aid debugging. Validate time zones with IANA names and reject ambiguous locales.
Do I need to care about leap seconds when I add the time? Most application stacks effectively ignore leap seconds because POSIX time smears or truncates them. If you require sub-second precision across leap seconds, consult your platform’s timekeeping model and the upstream NTP/PTP configuration. For typical business apps, standard UTC arithmetic is sufficient.