I have a date objectdata = '2021-07-30T22:33:38.000Z' . I need to manipulate the string a bit, for example create a string like 'abc2021-07-30T22:33:38.000Z. If I use 'abc'+data, the result would become abcFri Jul 30 2021 15:33:38 GMT-0700 (Pacific Daylight Time)
is there a way to convert data object to a string type without changing the format?
You can use "abc" + data.toISOString(). By default, turning a Date instance into a string gets you a string in the form you've seen, but there are various ways of getting other formats.
The toString() method converts a Date object to a string.
Note: This method is automatically called by JavaScript whenever a Date object needs to be displayed as a string.
var d = new Date();
console.log(d.toString())