I am getting date into JSON as below :


It seems that date has been returned in milliseconds format.

Can anyone please suggest the way to convert it into normal date format and vice versa ?


This is known as a "Unix Timestamp" (number of milliseconds since January 1st, 1970, 00:00:00 GMT). In Apex Code, you can use DateTime.newInstance(unixTimestamp) to return a DateTime that contains the formatted date/time value. In JavaScript, use new Date(unitTimestamp) to get the same result. To convert back, in Apex Code, use myDate.getTime(), and in JavaScript, use the same function: myDate.getTime().


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.