> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# processDate

Parses various date string formats into Date objects, returning only the date part with time set to midnight.
This utility function provides robust date parsing capabilities for a wide range of common formats.

```typescript theme={null}
export declare function processDate(input: { date: string }): Date | null;
```

## Key features

* Returns only the date part (year, month, day)
* Time is always set to 00:00:00
* Supports multiple international formats
* Handles timezones and AM/PM formats

## Supported formats

The function handles these date format categories:

### Standard date formats

* `DD/MM/YYYY`: "22/11/2024", "13/12/2024"
* `MM/DD/YYYY`: "01/17/2025", "10/25/2024"
* Single-digit variants: "8/16/2019", "9/28/2024"

### Date-time combinations

* With 24-hour time: "22/11/2024 21:19:05"
* With AM/PM: "12/09/2024 9:00 AM"
* With dash separator: "12/19/2024 - 2:00 PM"

### Timezone support

* With timezone abbreviations: "10/23/2024 12:06 PM CST"
* With timezone offset: "01/17/2025 3:00:00 PM CT"

### Text month formats

* Short month: "5 Dec 2024", "11 Sep 2024"
* With time: "5 Dec 2024 8:00 AM PST"
* Full month: "November 14, 2024", "January 31, 2025, 5:00 pm"

## Examples

<CodeGroup>
  ```typescript Basic Usage theme={null}
  import { processDate } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    // Basic date string
    const date1 = processDate({ date: "22/11/2024" });
    console.log(date1); // 2024-11-22 00:00:00

    // Date with time (time is ignored)
    const date2 = processDate({ date: "5 Dec 2024 8:00 AM PST" });
    console.log(date2); // 2024-12-05 00:00:00
  }
  ```

  ```typescript Invalid Date theme={null}
  import { processDate } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    // Invalid date returns null
    const invalidDate = processDate({ date: "invalid date" });
    console.log(invalidDate); // will return null.
    if (invalidDate === null) {
      throw new Error("Invalid date");
    }
    return "should not reach here";
  }
  ```
</CodeGroup>

## Arguments

<ResponseField name="input" type="Object" required>
  The input object containing the date to process

  <Expandable title="properties" defaultOpen>
    <ResponseField name="input.date" type="string" required>
      A string containing a date in various possible formats
    </ResponseField>
  </Expandable>
</ResponseField>

## Returns: `Date | any`

Returns a `Date` object with only date components preserved (year, month, day), time always set to 00:00:00, or `null` if parsing fails
