avatar
get year month day from UNIX timestamp Javascript

> How to get year-month-day from JavaScript Date Objects

exports.handler = async (event, context) => {
    
  var res = new Date().toISOString().split('T')[0];
  
  const response = {
      statusCode: 200,
      body: JSON.stringify(res),
  };
  return response;
};

> Output

node -r esbuild-register run.ts
{ statusCode: 200, body: '"2022-12-17"' }
You need to login to do this manipulation!