Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

How to Handle Dates, Currency, and Coordinates Reliably in JavaScript

Six practical JavaScript pitfalls involving time-zone defaults, recurring local times, currency formatting, localized strings, GeoJSON coordinate order, and geographic metadata.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

JavaScript’s internationalization and location APIs can produce results that look reasonable but mean something different from what your application intended. Set locale, time zone, currency, coordinate order, datum, and units explicitly at system boundaries—and keep machine values separate from display text.

1. Date formatting can inherit the runtime’s defaults

Intl.DateTimeFormat uses the runtime’s default locale and time zone when you do not specify them. That means the same code can display differently on different devices or execution environments. When output must follow a particular audience or region, pass both values explicitly:

As an Amazon Associate I earn from qualifying purchases.

const formatter = new Intl.DateTimeFormat("en-GB", {
  timeZone: "America/New_York",
  dateStyle: "medium",
  timeStyle: "short"
});

formatter.format(new Date("2026-10-11T15:00:00Z"));

The locale controls conventions such as date ordering and wording; the IANA time-zone identifier controls which local time is shown. Identifiers include America/New_York and Australia/Sydney. See MDN’s Intl.DateTimeFormat reference for options and examples.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To check what the runtime actually selected—including defaults—inspect resolvedOptions():

console.log(formatter.resolvedOptions());

This returns the effective locale, calendar, numbering system, and time zone, among other formatter settings. It is useful for diagnosing a mismatch between an intended configuration and the formatter’s resolved behavior.

2. An instant is not the same thing as a local appointment time

A JavaScript Date represents an instant. Formatting that date in another time zone changes how the instant is displayed; it does not move the instant forward or backward. For example, one event can be shown as different wall-clock times in New York and Sydney while remaining the same point in time.

Recurring events such as “the meeting is at 9 a.m. every Monday in New York” have a different meaning from a fixed timestamp. For that kind of schedule, store the local date and time together with its governing time zone rather than relying on an unqualified timestamp. This is application data-model guidance: Intl.DateTimeFormat formats instants but does not define a complete recurring-event model.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Locale and currency are separate inputs

For currency output, provide both a locale and a currency code. The locale determines display conventions; the code identifies the currency. A locale alone is not a dependable way to choose whether an amount means dollars, euros, or yen.

const amount = 1234.5;

new Intl.NumberFormat("en-US", {
  style: "currency",
  currency: "USD"
}).format(amount);

new Intl.NumberFormat("de-DE", {
  style: "currency",
  currency: "EUR"
}).format(amount);

The currency option takes a code such as USD, EUR, or JPY. Display conventions can also affect fractional digits: JPY formatting, for example, illustrates that minor-unit display conventions are not the same as USD’s. Consult MDN’s Intl.NumberFormat options reference and its internationalization guide.

4. Localized strings are for people, not data exchange

Do not parse or compare formatted date and currency strings as if they were stable machine values. MDN notes that output may vary between implementations, even for the same locale, and may contain non-breaking spaces or bidirectional control characters. A string that appears visually identical can therefore differ at the code-point level.

Keep the underlying timestamp or numeric amount as data, and format it only when presenting it to a user. Avoid hardcoding localized output in tests as though every runtime must emit precisely the same sequence of characters. If you need a stable interchange format, define one separately from the localized display.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Browser geolocation and GeoJSON use different coordinate order

Browser geolocation exposes coordinates as named properties: latitude and longitude. GeoJSON geographic positions use an array with longitude first and latitude second: [longitude, latitude]. Copying values into an array without checking the contract can silently swap the location.

const position = await new Promise((resolve, reject) => {
  navigator.geolocation.getCurrentPosition(resolve, reject);
});

const { latitude, longitude } = position.coords;
const geoJsonPosition = [longitude, latitude];

RFC 7946 specifies the order: “The first two elements are longitude and latitude, or easting and northing, precisely in that order and using decimal numbers.” See RFC 7946, section 3.1.1, and MDN’s reference for browser GeolocationCoordinates.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

6. Coordinates also need a datum, units, and boundary rules

Two numbers do not fully describe a geographic position. GeoJSON geographic coordinates use decimal degrees in the WGS 84 coordinate reference system. An optional third position value represents elevation in meters relative to the WGS 84 reference ellipsoid. RFC 7946 advises implementations not to extend positions beyond three elements because the meaning of extra values is ambiguous. See RFC 7946, *The GeoJSON Format*.

Preserve accuracy and observation time

Browser geolocation data includes accuracy and a measurement timestamp alongside latitude and longitude. If an application uses a position to make decisions, retain or account for those fields where relevant; coordinates alone do not communicate how certain or how recent the observation is. MDN documents the coordinate properties in its GeolocationCoordinates reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not assume every bounding box is an ordinary min-to-max range

A GeoJSON bounding box that crosses the antimeridian can have an east longitude smaller than its west longitude. Code that always treats the west value as the minimum and east as the maximum can misinterpret the region. RFC 7946 includes antimeridian examples; use its specified bounding-box conventions rather than applying ordinary numeric range assumptions to every case.

Boundary checklist

  • Pass the intended locale and time zone when date output must be predictable.
  • Keep the event’s meaning clear: a fixed instant or a local recurring schedule tied to a time zone.
  • Specify a currency code independently from the locale.
  • Keep timestamps and numeric amounts separate from localized display strings.
  • Convert coordinates by property name, and document whether arrays use longitude-first ordering.
  • Record coordinate datum and units, and account for accuracy, observation time, and antimeridian cases when they matter.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.