Issue with time format

I have a small job that reconciles data in one store with a neo4j graph, everything runs swimmingly on laptop but when I move it to a container for execution I get the below error, does anyone have any ideas on where to start digging into the problem?

"database returned error [Neo.ClientError.Statement.TypeError]: Unable to construct ZonedDateTime value: Unknown time-zone ID: Local"

I am also getting this same error. Were you able to find what was causing it?

Would you mind sharing the query that causes this?

Here is a sample that causes it for me. Basically any create where I am setting a time.Time as property value:

_, err := s.WriteTransaction(func(tx neo4j.Transaction) (interface{}, error) {
  _, err := tx.Run(
	"CREATE (t:Test {created_at: $created_at})",
	  "created_at": time.Now(),

It works if I specify a timezone, eg. time.Now().UTC(). Not sure if that is the expected behavior.

I can confirm this is an issue, but I'm afraid this will be hard to fix (apart from explicitly setting a time zone with .UTC() or .In(*Location) or using aliases mentioned at the end).

Indeed, a raw time.Time instance corresponds to one of two Packstream types:

In your example, the constructed time.Time refers to an implicit "Local" time zone name, as Golang itself calls it (try e.g. time.Now().Location().String()). This is unfortunately an invalid time zone name.

An alternative would be to call .Zone() on the time.Time instance, but this won't solve the problem, since it potentially returns an abbreviated time zone name such as "CEST" in my current case, which is yet another invalid name (contrary to the valid "Europe/Paris" e.g.).

If you care about the time zone, you will have to set it explicitly as shown above.

If you do not care about the time zone, please cast the time.Time to one of the driver-specific, "time zone less" aliases:

  • neo4j.Date
  • neo4j.LocalTime
  • neo4j.LocalDateTime

While they're all aliases of the standard time.Time, they are actually needed by the driver to be able to disambiguate the data to send to/receive from the server.

Hope it helps!

1 Like

Got it. Thanks for the detailed explanation, it makes sense. I will stick to setting it explicitly.

1 Like