nats-io/nats-server · error

expected Zulu formatted DateTime, but got '%s'

Error message

expected Zulu formatted DateTime, but got '%s'

What it means

An item classified as a datetime was parsed with time.Parse using the fixed layout "2006-01-02T15:04:05Z", which only accepts Zulu (UTC, literal 'Z' suffix) timestamps. Any other format or offset fails and the parser reports the raw value.

Source

Thrown at conf/parse.go:372

				return fmt.Errorf("float '%s' is out of the range", it.val)
			}
			return fmt.Errorf("expected float, but got '%s'", it.val)
		}
		setValue(it, num)
	case itemBool:
		switch strings.ToLower(it.val) {
		case "true", "yes", "on":
			setValue(it, true)
		case "false", "no", "off":
			setValue(it, false)
		default:
			return fmt.Errorf("expected boolean value, but got '%s'", it.val)
		}

	case itemDatetime:
		dt, err := time.Parse("2006-01-02T15:04:05Z", it.val)
		if err != nil {
			return fmt.Errorf(
				"expected Zulu formatted DateTime, but got '%s'", it.val)
		}
		setValue(it, dt)
	case itemArrayStart:
		var array = make([]any, 0)
		p.pushContext(array)
	case itemArrayEnd:
		array := p.ctx
		p.popContext()
		setValue(it, array)
	case itemVariable:
		value, found, err := p.lookupVariable(it.val)
		if err != nil {
			return fmt.Errorf("variable reference for '%s' on line %d could not be parsed: %s",
				it.val, it.line, err)
		}
		if !found {
			return fmt.Errorf("variable reference for '%s' on line %d can not be found",

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Rewrite the value in Zulu form: YYYY-MM-DDTHH:MM:SSZ, e.g. 2024-01-02T15:04:05Z.
  2. Convert any timezone offset to UTC and suffix 'Z' instead of '+HH:MM'.
  3. Drop fractional seconds or move the timestamp to a string field and parse it yourself with time.RFC3339.
  4. Quote the value as a string if you must keep the original format.

Example fix

// before
expires = 2024-01-02T15:04:05+02:00
// after
expires = 2024-01-02T13:04:05Z
Defensive patterns

Strategy: validation

Validate before calling

if _, err := time.Parse("2006-01-02T15:04:05Z", raw); err != nil {
	t, err2 := time.Parse(time.RFC3339, raw)
	if err2 != nil { return err }
	raw = t.UTC().Format("2006-01-02T15:04:05Z")
}

Prevention

When it happens

Trigger: processItem (from parse) hits case itemDatetime with values like '2024-01-02 15:04:05', '2024-01-02T15:04:05+02:00', '2024-01-02', or RFC3339 with nanoseconds '2024-01-02T15:04:05.123Z'.

Common situations: Copying timestamps from logs or other systems in local-time or with timezone offsets, omitting the 'T'/seconds, or including fractional seconds.

Related errors


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/e0dfce1d4b4f084f. Report an issue: GitHub.