• How to extract the UNIX timestamp string to the array of iso date string.
exports.handler = async (event, context) => {
var str = "/1671295510000/1671296638000/1681297757100/";
var dates = str.match(/\d+/g).map(function(s) {
return new Date(+s).toISOString();
});
const response = {
statusCode: 200,
body: JSON.stringify(dates),
};
return response;
};
» Output
node -r esbuild-register run.ts
{
statusCode: 200,
body: '["2022-12-17T16:45:10.000Z","2022-12-17T17:03:58.000Z","2022-12-17T17:22:37.000Z"]'
}