Convert Unix epoch time/date to something readable

I am creating a chart from an API REST call. I get the data in no problem but the date/time comes in as unix epoch format, curious if any you unix guys know an easy way to do this in wappler using the formatter?

Here is a link about converting epoch format:

https://www.epochconverter.com/

I am currently using IIS and asp, so I didn’t know if I would have to write some sort of javascript to format the date/time the way I need it or there was some fancy way the wappler formatter could deal with it?

If you can convert your Unix Epoch to ISO then you’ll be able to manipulate it within the formatter.

var s = new Date(timestamp * 1000).toISOString();
s; // => "2019-10-23T12:17:24.000Z"

Replace timestamp with your original date/time.

Or you could do a similar calculation with moment.js - https://stackoverflow.com/a/51706404

yeah wasn’t sure if there was a way to do it with the formatter though? since having to deal with the REST API and chart extension

Just use the formatDate formatter, numbers will be handled as unix timestamps.

{{ timestamp.formatDate('dd-MM-yyyy HH:mm') }}
1 Like