skip to Main Content

I am using JavaScript date method for date and getting mentioned result.

const d = new Date();

output is: Tue May 07 2024 14:57:43 GMT+0530 (India Standard Time)

But I need this format

IST instead of India Standard Time

Tue May 07 2024 14:57:43 GMT+0530 (IST)

2

Answers


  1. Maybe;

    const d = new Date();
    console.log(d.toLocaleTimeString('en-us',{timeZoneName:'shortGeneric'}));
    Login or Signup to reply.
  2. const newDate = new Date();
    const newDateToString = newDate.toLocaleTimeString('en-us',{timeZoneName:'shortGeneric'});
    const replaceString = newDateToString.replace("India Standard Time", "(IST)")
    console.log(replaceString);
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search