Welcome, but please don’t bump multiple old topics with the same question. I’ve removed your other post. Also, a link to a reference solution (in the code of the deprecated SDK) has been provided in this very topic.
So: what is not working for you?
See also a simpler (but quite specific) working example in Time synchronisation of a Node.