Skip to content
0

katanakit-js / useFakeDate

Function: useFakeDate() ​

ts
function useFakeDate(from?, to?): Promise<Date>;

Defined in: src/core/services/faker.service.ts:217

Generates a random date within an optional range.

Parameters ​

ParameterTypeDescription
from?string | number | DateLower bound (default: 1970-01-01).
to?string | number | DateUpper bound (default: faker's reference date, see useFakeSetDefaultRefDate — the current time when unset).

Returns ​

Promise<Date>

A Date instance.

Example ​

ts
const hiredAt = await useFakeDate(new Date("2020-01-01"), new Date("2025-12-31"));

Released under the MIT License.