Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Hooks & Utilities

Date utils

Hooks & Utilities

Date utils TypeScript helper for React

CommerceFile export
Live props
Options
locale
text
  1. Home
  2. Components
  3. Hooks & Utilities
  4. Date utils
Pro

Date utils TypeScript helper for React

v1.0.0·Added in 1.0.0

Locale-aware date helpers for React date pickers and calendars: week start, month and weekday names, typed-date parsing, grids and presets.

Pick a locale and the month grid reorders itself: Sunday first in en-US, Monday first in en-GB and ro-RO, Saturday first in ar-EG, with the names from Intl. Type a date the way people do (9/23, 23/9/26, tomorrow, +3) and see what it parses to. The preset list shows the usual report ranges for today.

Date utils is a Pro React helper in the React hooks and utilities category, written in TypeScript for React 19. It installs as source with npx wingo-ui@latest add date-utils, together with the npm package date-fns.

Add to a project

Requirements: React 19, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add date-utils

Date utils is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans

Usage

Import parseDate from @/lib/date-utils.

import { formatDate, getWeekStartsOn, parseDate } from "@/lib/date-utils"

const date = parseDate("9/23", { locale: "en-US" })
formatDate(date, "en-US") // "09/23/2026"
getWeekStartsOn("en-US") // 0 (Sunday)
getWeekStartsOn("ro-RO") // 1 (Monday)

API

  • localedefault "en-US"
    string

    The demo's locale. Every helper takes an optional locale; pass the one from useLocale so server and browser agree.

  • textdefault ""
    string

    The demo's typed date, parsed with parseDate in the locale (English keywords by default, Romanian ones such as maine when the locale is ro-RO).

  • parseDate
    (text: string, options?: { locale?: string; reference?: Date; keywords?: { today?, tomorrow?, yesterday?: string[] } }) => Date | null

    A typed date or null. The locale's field order with . / - or spaces, 1 or 2 digit day and month, a 2 digit year (nearest century) or none (this year), ISO "2026-09-23" in any locale, keywords without case or diacritics, and "+3" / "-2" for days from today. 31.02 is rejected, never rolled over.

Parts

  • getWeekStartsOn

    function

    The first day of the week for a locale, 0 (Sunday) to 6 like date-fns: 0 in en-US, 1 in en-GB and de-DE, 6 in ar-EG. From Intl week info where the browser has it, from a CLDR table where it does not (Firefox).

  • getWeekendDays

    function

    The weekend days for a locale as weekday numbers: [6, 0] in en-US, [5, 6] in ar-EG. Calendars use it to tint weekends.

  • getHourCycle

    function

    Whether a locale writes times on a 12 hour ("h12", en-US) or 24 hour clock ("h23", en-GB, de-DE).

  • capitalize

    function

    Uppercases the first letter in the locale's rules, for month names that Intl writes in lowercase in some languages.

  • getMonthNames

    function

    The twelve month names from Intl, January first and capitalized, in "long", "short" or "narrow" form. No bundled locale data.

  • getWeekdayNames

    function

    Weekday names in display order from weekStartsOn, in "long", "short", "min" or "narrow" form. "min" is the two-letter calendar header (Su Mo Tu We Th Fr Sa).

  • formatMonthYear

    function

    The calendar caption for a month: "September 2026" in en-US.

  • getDateOrder

    function

    How a locale writes a numeric date: { order, separator, pattern }, e.g. MM/dd/yyyy in en-US and dd.MM.yyyy in de-DE.

  • autoFormatDateInput

    function

    Inserts the locale's separators while someone types digits into a date field: "0923" becomes "09/23/" in en-US. Text with letters, like "tomorrow", passes through.

  • formatDate

    function

    A date in the locale, numeric by default ("09/23/2026" in en-US) or with any Intl options ({ dateStyle: "medium" } gives "Sep 23, 2026"). "" for null or an invalid date.

  • formatDateRange

    function

    A range through Intl formatRange, which writes the shared month and year only once. While only the start is picked it prints the start alone, followed by a dash.

  • formatDayLabel

    function

    The long spoken form of a day for a day button's aria-label: "Wednesday, September 23, 2026".

  • toISODate

    function

    "2026-09-23" in local time for hidden form inputs. Never uses toISOString, which converts to UTC and can land on the previous day.

  • toISODateTime

    function

    "2026-09-23T14:30" in local time, for date and time inputs.

  • fromISODate

    function

    Reads "2026-09-23" or "2026-09-23T14:30" back into a local Date; null when the text is not one.

  • matchesDate

    function

    Whether a day matches a DateMatcher or a list of them. Calendars use it for disabled and marked days.

  • isDateUnavailable

    function

    Whether a day falls outside min or max (by calendar day) or matches disabled. Takes (date, { min?, max?, disabled? }).

  • getMonthWeeks

    function

    The weeks of a month grid, 7 days each from weekStartsOn, including the neighbor month's days that fill the first and last week. fixedWeeks always returns 6 weeks so the grid never changes height.

  • normalizeRange

    function

    Puts from before to, swapping a range picked backwards. Nulls stay.

  • isInRange

    function

    Whether a day is inside a range, both ends included.

  • countDays

    function

    The days in a range, both ends included (a 3 night hotel stay is 4 days); 0 while the range is incomplete.

  • getDatePresets

    function

    Single-day presets from a reference day: today, tomorrow, yesterday, nextWeek (same weekday) and nextMonth. Labels are the picker's job.

  • getRangePresets

    function

    The usual report ranges from a reference day, ends included: last 7 days, this month, last quarter and more. "Last 7 days" ends today.

  • parseTime

    function

    What someone typed as an "HH:mm" string, or null: "14:30", "1430", "14.30", "2:30 pm", "2p", "12am". Locale-free like <input type="time">.

  • formatTime

    function

    An "HH:mm" value in the locale: "2:30 PM" in en-US, "14:30" in en-GB. hourCycle forces a 12 or 24 hour clock.

  • getDayPeriodLabels

    function

    The locale's AM and PM labels, for a time picker's period toggle.

  • timeToMinutes

    function

    "14:30" to 870 minutes after midnight; null when the value is not a time.

  • minutesToTime

    function

    870 to "14:30", wrapping around midnight.

  • setTime

    function

    A new Date on the same day at an "HH:mm" time.

  • getTimeOfDay

    function

    The "HH:mm" time of a Date.

  • DateRange

    type

    { from: Date | null; to: Date | null }, the value of range pickers.

  • DateMatcher

    type

    What a calendar can disable or mark: a Date, a Date[], { from, to }, { before }, { after }, { dayOfWeek } or (date) => boolean.

  • Weekday

    type

    0 (Sunday) to 6 (Saturday), like date-fns.

  • ParseDateOptions

    type

    parseDate's options: locale, reference (the day "tomorrow" counts from) and keywords per language.

Examples

Week start by locale

Calendar headers and numeric date patterns straight from Intl.

Typed dates

parseDate in en-US with today fixed to Sep 23, 2026; Feb 31 is rejected, never rolled over.

Report ranges

getRangePresets with formatDateRange and countDays, both ends included.

Typed times

parseTime turns loose input into HH:mm; formatTime shows it per locale.

Dependencies

date-fns

Files

  • lib/date-utils.ts

FAQ

Is the Date utils helper free?

The preview, props and docs are free; copying the source needs a Pro plan. See plans.

How do I install Date utils?

Run npx wingo-ui@latest add date-utils. It also adds the npm package date-fns. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/date-utils.

See also

Number formatlibText matchlibuseLocalehook

Used in

Listing cardCalendarKanbanTrackerHeatmap calendarOrder trackerDate Range PickerData TableDeal PipelineSeller cardCron PickerDate Picker

and 31 more.

More React hooks and utilities

File exportlibFile typeslibFilterslibForm validationlibHapticslibInvoicinglib
All 36 React hooks and utilities
PreviousCommerceNext File export

November 2026

weekStartsOn 0
SuMoTuWeThFrSa
12345678910111213141516171819202122232425262728293012345
Typed date
mm/dd/yyyy

Type in the controls: 9/23, 23/9/26, tomorrow, +3

Last 7 daysNov 1 – 7, 2026
This monthNov 1 – 30, 2026
Last quarterJul 1 – Sep 30, 2026