[solved] Javascript postupdate datetime format?

I’m trying to update an item which is Datetime in Javascript

items.getItem(“Door_Last_Opened”).postUpdate( time.ZonedDateTime.now());

What format do I use in Javascript to update Openhab datetime item?

I’m getting the following error:

2021-12-31 16:02:40.036 [ERROR] [org.openhab.automation.script.rules ] - Failed to execute rule Garage-Doors-change-db41a565-4d44-47d1-8010-cf86bb5bb9ee: java.lang.UnsupportedOperationException: Unsupported operation identifier ‘toFullString’ and object ‘[object Object]’(language: JavaScript, type: ZonedDateTime). Identifier is not executable or instantiable.: undefined

Have you seen this tutorial on date and time conversion?
There is a conversion from java time to a datetimetype included.

thanks but it looks like all those examples are for DSL not Javascript.

This is working for me:

  var date = Date.now();
1 Like