-1

I need to Convert epoch time to human-readable date

Timestamp value is: = '1685595600'

Need to convert above timestamp like this

date = 01 Month = 06 year = 2023

How should it be done?

  • next time for `karate` questions don't add `javascript` or `java` tags. please refer to this answer: https://stackoverflow.com/a/60945563/143475 – Peter Thomas Jun 21 '22 at 15:40

1 Answers1

0

You could create a new Date object from the timestamp and then use its methods to retrieve the day, month and year.

const timestamp = new Date().getTime(); // current timestamp
const date = new Date(timestamp);

const day = date.getUTCDate();
const month = date.getUTCMonth() + 1; // January is 0
const year = date.getUTCFullYear();

console.log(day, month, year);