.toString()
Anonymous contributor
Anonymous contributor2 total contributions
Anonymous contributor
Published Jul 22, 2021Updated May 31, 2023
Contribute to Docs
Converts a Date object to a string.
Syntax
myDate.toString();
Example 1
Print the Date object as a string:
const currentDate = new Date('July 15, 2021 11:48:57');console.log(typeof currentDate);// Output: objectconst currentDateString = currentDate.toString();console.log(typeof currentDateString);// Output: stringconsole.log(currentDateString);// Output: Thu Jul 15 2021 11:48:57 GMT-0700 (Pacific Daylight Time)// Note: Timezone may vary
Codebyte Example
The following is runnable, and demonstrates the use of the .toString()
method.
All contributors
- Anonymous contributorAnonymous contributor2 total contributions
- christian.dinh2476 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- robgmerrill124 total contributions
- Anonymous contributor
- christian.dinh
- Anonymous contributor
- robgmerrill
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.