How to use Date.toGMTString() method In Javascript
The date.toGMTString() method is used to convert the given date object’s contents into a string according to the Greenwich Mean Time GMT.
Example: In this example, we will convert the date object to a string using the Date.toGMTString() method.
// New date using date Constructor
let d = new Date()
// Convert to string
let dateString = d.toGMTString();
// Print output
console.log(dateString)
Output
Wed, 20 Sep 2023 08:42:52 GMT
JavaScript Program to Convert Date to String
In this article, we will see how to convert a JavaScript Date to a string using JavaScript. We have a few methods to convert JavaScript Date to string which are described below.