Skip to main content
export declare function processDate(input: { date: string }): Date | null;
Parses various date string formats into Date objects. Returns only the date part (year, month, day) with time set to 00:00:00. Supports a wide variety of date formats including:
  • DD/MM/YYYY with optional time (e.g., “22/11/2024 21:19:05”, “13/12/2024”)
  • MM/DD/YYYY with optional time and timezone (e.g., “01/17/2025 3:00:00 PM CT”, “10/25/2024”)
  • MM/DD/YYYY with time and timezone abbreviations (e.g., “10/23/2024 12:06 PM CST”)
  • MM/DD/YYYY with AM/PM time format (e.g., “11/28/2024 1:59:59 AM”, “12/09/2024 9:00 AM”)
  • MM/DD/YYYY with dash separator and time (e.g., “12/19/2024 - 2:00 PM”)
  • M/DD/YYYY and MM/D/YYYY formats (e.g., “8/16/2019”, “9/28/2024”)
  • DD MMM YYYY with optional time and timezone (e.g., “5 Dec 2024 8:00 AM PST”, “11 Sep 2024”)
  • Full month name formats (e.g., “November 14, 2024”, “January 31, 2025, 5:00 pm”)
  • 24-hour time format (e.g., “22/11/2024 19:45:00”, “09/01/2025 15:00:00”)

Examples

import { processDate } from "@intuned/browser";
export default async function handler(params, page, context){
processDate("22/11/2024 21:19:05") // Returns Date with 2024-11-22 00:00:00
processDate("5 Dec 2024 8:00 AM PST") // Returns Date with 2024-12-05 00:00:00
}

Arguments

input
Object
required
The input object containing the date to process

Returns: Date | any

Date object with only date components (time set to 00:00:00) if parsing successful, null if parsing fails