LocalDateTime — GraphQL Custom Scalar

Author – ChilliCream

Date – 2025-12-24

1Overview

The LocalDateTime scalar type represents a date and time without time zone information. It is intended for scenarios where time zone context is either unnecessary or managed separately, such as recording birthdates and times (where the event occurred in a specific local context), displaying timestamps in a user’s local time zone (where the time zone is known from context), or recording historical timestamps where the time zone was not captured.

Unlike instant-based DateTime scalars that represent a specific moment in time, LocalDateTime represents a calendar date and wall-clock time that could refer to different moments depending on the time zone context applied to it. This makes it suitable for applications where the time zone is managed separately from the date-time value itself.

The scalar uses RFC 3339 format for serialization, specifically the full-date and partial-time productions combined with a T or t separator, but without time zone offset information.

3Result spec

A LocalDateTime scalar must serialize to a string conforming to the RFC 3339 full-date and partial-time productions combined with a T or t separator, but without the time-offset component. This represents a local date and time in the format: YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm:ss.fffffffff (with optional fractional seconds).

The format is:

The serialized value must not include time zone offset information (e.g., Z, +00:00, or -05:00) as specified in the RFC 3339 time-offset production.

3.1Examples

These are valid result values:

Value Explanation
"2023-12-24T15:30:00" A LocalDateTime without fractional seconds.
"2023-12-24t15:30:00" The t separator may be lowercase.
"2023-12-24T15:30:00.123" A LocalDateTime with millisecond precision.
"2023-12-24T15:30:00.123456789" A LocalDateTime with nanosecond precision.
"2023-01-01T00:00:00" Midnight on January 1st.
"2023-12-31T23:59:59" One second before midnight on December 31st.

These are invalid result values:

Value Why is it invalid
"2023-12-24T15:30:00Z" Contains time zone indicator Z.
"2023-12-24T15:30:00+00:00" Contains time zone offset.
"2023-12-24 15:30:00" Missing T or t separator.
"2023-12-24" Missing time component.
"15:30:00" Missing date component.
"2023-13-01T00:00:00" Invalid month (13).
"2023-12-32T00:00:00" Invalid day (32).
"2023-12-24T15:30:00.1234567890" More than 9 fractional second digits.
"2023-12-24T24:00:00" Invalid hour (24).
"2023-02-30T15:30:00" Invalid date (February 30th).

4Input spec

A LocalDateTime scalar accepts string values conforming to the RFC 3339 full-date and partial-time productions combined with a T or t separator, but without the time-offset component, both as GraphQL literals and as JSON input values.

The input format matches the result format and must:

Implementations should validate:

4.1Examples

Valid input values:

GraphQL Literal:

mutation {
  updateProfile(birthDateTime: "2023-12-24T15:30:00") {
    id
  }
}

JSON input:

{
  "birthDateTime": "2023-12-24T15:30:00"
}
{
  "birthDateTime": "2023-12-24t15:30:00.123456789"
}

Invalid input values:

Value Why is it invalid
"2023-12-24T15:30:00Z" Contains time zone indicator Z.
"2023-12-24T15:30:00+05:30" Contains time zone offset.
"2023-12-24 15:30:00" Invalid separator (space instead of T or t).
"2023-12-24T25:00:00" Invalid hour (25).
"2023-12-24T15:60:00" Invalid minute (60).
"2023-02-30T15:30:00" Invalid date (February 30th).
"2023-12-24T15:30:00.1234567890" More than 9 fractional second digits.

5References

  1. 1Overview
  2. 2Recommended name
  3. 3Result spec
    1. 3.1Examples
  4. 4Input spec
    1. 4.1Examples
  5. 5References