1

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?

1
  • 1
    You can Edit your question Commented Aug 2, 2021 at 23:40

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@RobG yea I chose the term badly; I meant a date that, well, looks like what they were complaining about. I'll update the answer.
0

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())

more on this topic

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.