cd /news/ai-tools/my-billing-form-thought-it-was-yeste… · home › topics › ai-tools › article
[ARTICLE · art-182590] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=· neutral

My Billing Form Thought It Was Yesterday. I Live Five Hours Ahead of UTC.

A developer building VoiceDash, a white-label client portal for voice AI agencies, fixed two billing date bugs caused by deriving calendar dates from UTC instead of the user's local time zone. Subscription start dates and coupon expiry dates were each off by one day for agencies east or west of UTC, causing subscriptions to be scheduled rather than started immediately and coupons to display or expire on the wrong day. The fix moves date conversion into the browser, where the agency's time zone is known, so 'today' reflects local midnight rather than Greenwich.

recommendation

Compute calendar dates in the browser using the user's time zone offset rather than toISOString(), and convert local midnight to a timestamp server-side before scheduling billing.

more in playbook: Running AI in production
by read6 min views6 publishedDec 5, 2026

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 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.

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.

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:

getTimezoneOffset() returns minutes toISOString() gives you the local calendar date in YYYY-MM-DD. toLocaleDateString("en-CA") gets you the same shape, but I wanted something that does not depend on a locale's formatting choices.date <= today() compares two ISO dates as strings, and zero-padded new Date("2026-10-11") is parsed as midnight new Date("2026-10-11T00:00:00") is parsed as midnight 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.

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.

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. 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?

── more in #ai-tools 4 stories · sorted by recency
── more on @voicedash 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/my-billing-form-thou…] indexed:0 read:6min 2026-12-05 · —