[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Type](https://evolu.dev/docs/api-reference/common/Type) › ValidDate

```ts
const ValidDate: brand(
  "ValidDate",
  Date,
  (value: globalThis.Date) =>
    globalThis.Number.isNaN(globalThis.Date.prototype.getTime.call(value))
      ? err<ValidDateError>({ type: "ValidDate", value })
      : ok(),
  formatValidDateError,
);
```

Defined in: [packages/common/src/Type.ts:4071](https://github.com/evoluhq/evolu/blob/bc4578a260dd15d5bbf94b83765ca05984d194cb/packages/common/src/Type.ts#L4071)

A [Date](https://evolu.dev/docs/api-reference/common/Type/variables/Date) with a valid time value.

Rejects an Invalid Date, such as `new Date("x")`, whose time value is NaN.
Like Date, it is realm-neutral: it reads the time value with
`Date.prototype.getTime` instead of a method of the value.

A Date is mutable, so calling `setTime(NaN)` on a validated value breaks its
brand. Use [DateIsoFromDate](https://evolu.dev/docs/api-reference/common/Type/variables/DateIsoFromDate) to store a moment and [Millis](https://evolu.dev/docs/api-reference/common/Time/variables/Millis) for
time arithmetic.

### Example

```ts
import {
  assertEqual,
  assertErr,
  assertOk,
  assertType,
  ValidDate,
  type Brand,
} from "@evolu/common";

const date = new Date(0);
assertOk(ValidDate.fromUnknown(date), date);
assertType<ValidDate, Date & Brand<"ValidDate">>();

const invalidDate = new Date("x");
const invalid = ValidDate.fromUnknown(invalidDate);
assertErr(invalid, { type: "ValidDate", value: invalidDate });
assertEqual(ValidDate.formatError(invalid.error), "The Date is invalid.");
```