Display NTP binding to unix timestamp

Hello,
How can I display the timestamp from the NTP binding ?not formatted simply the Unix timestamp.

Thanks

Link it to a DateTime type Item, then display or use in a rule the string value of the Item.

if you’re after the Epoch e.g. single integer value, see here -

Can you post a sample please?

No, I don’t know where you want to use it. In a rule? What language of rule? Log the value? Display in a UI?

I want to display it in the ui

Have you decided if it is really ‘epoch’ form you are after yet?

If you don’t want to create another Item to hold it as a string, I think you could write a javascript JS transform to use in the DateTime item’s label.
The javascript would get an ISO string like
2018-05-05T05:55:55.000-04:00
which you would need to parse into a javascript object, then get the milliseconds epoch to return to openHAB.
Some ideas here -

What is wrong with this transformation?

(function(i) {
    var date = new Date(i); // some mock date
    var response = date.getTime(); 
    return response;
}) (input)

it shows me now


DateTime	date_actualntptimestamp	"Date  [JS(timetotimestamp.js):%s]"	<time>	{channel="ntp:ntp:smarthome:dateTime"}
result:
1.596436653672E12

Have you come across “scientific notation” before?
This is just another way to write
1596436653672
which is a milliseconds epoch for
Monday, August 3, 2020 6:37:33.672
Your script gives the right value, but you don’t like the format I guess.

If you want to format your number another way, you should do that in your javascript too. I think maybe a simple .toString() would do it.