Skip to main content

Date Generator

Generates random dates and timestamps within a specified range.

Basic Usage

{
"createdAt": {"gen": "date"}
}

Output: Random date between 1970-01-01 and one year from now in ISO format

Options

OptionTypeDefaultDescription
fromstring"1970-01-01"Start date (ISO format)
tostringOne year from nowEnd date (ISO format)
formatstring"iso"Output format

Format Options

FormatDescriptionExample Output
isoISO date (YYYY-MM-DD)2024-03-15
iso_datetimeISO datetime2024-03-15T14:30:00Z
timestampUnix timestamp (milliseconds)1710512400000
epochUnix timestamp (seconds)1710512400
Custom patternJava date patterndd/MM/yyyy15/03/2024

Examples

Basic Date Range

{
"birthDate": {
"gen": "date",
"from": "1950-01-01",
"to": "2005-12-31"
}
}

Recent Dates

{
"createdAt": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31"
}
}

ISO Datetime

{
"timestamp": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31",
"format": "iso_datetime"
}
}

Output: 2024-06-15T14:30:45Z

Unix Timestamp

{
"createdAt": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31",
"format": "timestamp"
}
}

Output: 1718462445000

Epoch Seconds

{
"createdAt": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31",
"format": "epoch"
}
}

Output: 1718462445

Custom Format

{
"displayDate": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31",
"format": "dd/MM/yyyy"
}
}

Output: 15/06/2024

US Format

{
"date": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31",
"format": "MM-dd-yyyy"
}
}

Output: 06-15-2024

Common Patterns

User Records

{
"users": {
"count": 100,
"item": {
"id": {"gen": "uuid"},
"name": {"gen": "name.fullName"},
"birthDate": {
"gen": "date",
"from": "1960-01-01",
"to": "2005-12-31",
"format": "iso"
},
"createdAt": {
"gen": "date",
"from": "2020-01-01",
"to": "2024-12-31",
"format": "iso_datetime"
}
}
}
}

Event Logs

{
"events": {
"count": 1000,
"item": {
"id": {"gen": "uuid"},
"eventType": {"gen": "choice", "options": ["login", "logout", "purchase"]},
"timestamp": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31",
"format": "timestamp"
}
}
}
}

Orders

{
"orders": {
"count": 500,
"item": {
"id": {"gen": "uuid"},
"orderDate": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31",
"format": "iso"
},
"deliveryDate": {
"gen": "date",
"from": "2024-01-01",
"to": "2024-12-31",
"format": "iso"
}
}
}
}

Time Series Data

{
"measurements": {
"count": 1000,
"item": {
"id": {"gen": "uuid"},
"timestamp": {
"gen": "date",
"from": "2024-01-01T00:00:00",
"to": "2024-01-31T23:59:59",
"format": "iso_datetime"
},
"value": {"gen": "float", "min": 0, "max": 100, "decimals": 2}
}
}
}

Custom Date Patterns

Common Java date format patterns:

PatternDescriptionExample
yyyy-MM-ddISO date2024-03-15
dd/MM/yyyyEuropean format15/03/2024
MM-dd-yyyyUS format03-15-2024
yyyy-MM-dd HH:mm:ssDatetime2024-03-15 14:30:45
dd MMM yyyyMonth name15 Mar 2024
EEEE, MMMM dd, yyyyFull formatFriday, March 15, 2024

Best Practices

  1. Use ISO Format: Default to ISO for consistency
  2. Realistic Ranges: Choose date ranges that match your use case
  3. Timestamps for Logs: Use timestamp or epoch for event logs
  4. Custom Formats: Use custom patterns for display dates
  5. Consider Timezones: ISO datetime includes timezone (Z for UTC)

Next Steps