I live in Pakistan, five hours ahead of UTC. At 01:22 on a Sunday in October I committed a fix to VoiceDash, my white-label client portal for voice AI agencies, and the commit message starts like this:
The form took today from UTC, so agencies east of UTC could see yesterday...
Look at the timestamp. Between midnight and 5am my time, JavaScript's favorite way to get "today" returns yesterday, which is exactly the window that commit landed in.
This is a short build-log about two billing dates that were each off by one day, the fix, and the parts of the same app that are still on UTC as I write this.
The one-liner everyone writes
The subscription form, where an agency bills one of its clients through its own Stripe account, had this at the top:
const today = () => new Date().toISOString().slice(0, 10); It feeds a date input:
<input type="date" value={startDate} min={today()} ... /> toISOString() always renders in UTC. So today() is not today. It is today in Greenwich. For most of the day that is the same calendar date as yours, which is exactly why it survives code review and manual testing.
Here is what it did on each side of the world.
East of UTC (me, at 1am). The form defaults to yesterday. If you leave it alone, nothing bad happens, because the server treats a past or current date as "start now". But it looks wrong, so a careful agency owner changes it to their actual today. The server then did this:
function scheduleStart(startDate?: string | null): number | "now" { if (!startDate) return "now"; const start = Date.parse(`${startDate}T00:00:00Z`); if (!Number.isFinite(start)) throw new BillingError("Invalid start date."); return start <= Date.now() ? "now" : Math.floor(start / 1000); } Midnight UTC of "my today" is 5am my time, still hours away. So the subscription is saved as scheduled instead of active, and the first charge waits for UTC to catch up. The agency asked for "start now" in the only way the form let them, and got "start later".
West of UTC (a US agency in the evening). After 7pm in New York (8pm during daylight saving), UTC is already on tomorrow. The form defaults to tomorrow, and because min={today()}, the agency cannot even select their own today. It still works, since tomorrow-in-UTC parses to a moment that has already passed, but the screen is telling them a date that is not true.
Nobody gets a crash. You get a form that is subtly wrong for a few hours a day, depending on where your customer lives. That is the worst kind of bug to find from your own desk, unless your desk happens to be at UTC+5 after midnight.
The second one: Dec 31 showed as Jan 1
Coupons had the mirror image of the same bug. The agency picks "can be redeemed until" from a date input, the form sends the bare YYYY-MM-DD, and the API route did:
const ts = Math.floor(Date.parse(`${b.redeemBy}T23:59:59Z`) / 1000); params.redeem_by = ts; End of day, in UTC. Then the coupon details panel formats that timestamp in the browser:
return d.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" }); 23:59:59 UTC on December 31 is 04:59 on January 1 in Karachi. So an agency that typed Dec 31 saw "Jan 1" in the details panel, and in US time zones the coupon really did stop working several hours before their Dec 31 ended. The value round-tripped through two time zones and came back as a different day.
What the fix actually is
The core insight is boring once you see it: a date is not a moment. "October 11" is a calendar label. It only becomes a point in time when you attach a time zone, and the server did not know the agency's time zone. The browser does.
So the conversion moved to the browser:
/** Today in the agency's own timezone, as the date input's YYYY-MM-DD. */ const today = () => { const d = new Date(); return new Date(d.getTime() - d.getTimezoneOffset() * 60_000).toISOString().slice(0, 10); }; /** Today starts billing now; a later day starts at the agency's local midnight. */ const startAt = (date: string) => !date || date <= today() ? null : new Date(`${date}T00:00:00`).toISOString(); Three small things in there are worth knowing:
- The offset trick.
getTimezoneOffset()returns minutes behind UTC (it is -300 for me). Shifting the timestamp by it and then callingtoISOString()gives you the local calendar date inYYYY-MM-DD.toLocaleDateString("en-CA")gets you the same shape, but I wanted something that does not depend on a locale's formatting choices. - Plain string comparison works.
date <= today()compares two ISO dates as strings, and zero-paddedYYYY-MM-DDsorts the same way lexically and chronologically. - The parsing gotcha.
new Date("2026-10-11")is parsed as midnight UTC.new Date("2026-10-11T00:00:00")is parsed as midnight local time. The spec says a date-only string is UTC and a date-time without an offset is local. I have known this for years and still wrote the UTC version first.
The form now sends a full ISO timestamp (or null for "now"), and the server accepts both shapes:
const start = Date.parse( /^\d{4}-\d{2}-\d{2}$/.test(startDate) ? `${startDate}T00:00:00Z` : startDate ); A bare date still means midnight UTC, so anything calling the API directly keeps its old behavior. The coupon form got the same treatment the next day: it sends new Date(`${redeemBy}T23:59:59`).toISOString(), the end of the chosen day in the agency's own zone, and its min uses the same offset trick.
The rule I took away: the edge that knows the time zone converts dates to instants. Everything behind it only sees instants.
What is still on UTC
I went looking for the rest of the pattern while writing this, and the honest answer is that the billing forms are fixed and the analytics are not.
The client analytics endpoint groups calls into days like this:
const dateKey = conv.startedAt.toISOString().split("T")[0]; and builds the "calls by hour" chart with:
const hour = c.startedAt.getHours(); Both run on the server, and the server runs in UTC (the default on Vercel, where it is hosted). For a client in New York, every call after 8pm (7pm in winter) lands on tomorrow's bar, and the busiest-hours chart is shifted by four or five hours. The dashboard is not lying about the totals, it is just drawing them on Greenwich's calendar. (That endpoint also rounds minutes per call before summing, which I wrote about in my zero-test-files post.)
The trial emails have a smaller version of it: the "your trial ends on..." date is formatted server-side with toLocaleDateString("en-US", ...) and no timeZone option, so it is the UTC date of the trial end. For someone who signed up on a US evening, that can read as the day after their own.
The fix I have not shipped yet is the same rule applied one layer down: the dashboard already builds its range in the browser, so it can also send Intl.DateTimeFormat().resolvedOptions().timeZone, and the server can bucket with Intl.DateTimeFormat(..., { timeZone }) instead of toISOString(). There is also a design question I have not answered: the browser's zone is where the viewer is, not where the business is. An agency owner in Lahore looking at a Texas client's calls probably wants Texas days. That points at a time zone stored per client, which the schema does not have today.
What I would tell myself before writing the form
- Grep for
toISOString().slice(0, 10)and.split("T")[0]. Every hit is a place where "today" or "this day" means UTC, whether you meant it or not. - Decide for each date field whether it is a calendar label or a moment, and convert at the one place that knows the zone.
- Test your date screens at a time of day when UTC is on a different date from you. If you are in the Americas, that is your evening. If you are in Asia, it is your early morning. My fix landed at 1:22am, which says something about my sleep and also about when these bugs show up.
If you have a SaaS where customers in different zones look at the same data, I am curious where you store the zone: per user, per account, or per the thing being measured?

