JavaScript tutorial:
toGMTString method

 

Applies to: Date Object

The toGMTString is use to converted a date to a string using Greenwich Mean Time(GMT).

Syntax

objDate.toGMTString()

Return

Returns a string using Greenwich Mean Time(GMT) format.

Example

The toGMTString method is obsolete, and is provided for backwards compatibility only. It is recommended that you use the toUTCString method instead.

The toGMTString method returns a String object that contains the date formatted using GMT convention. The format of the return value is as follows: "05 Jan 1996 00:00:00 GMT."

The following example illustrates the use of the toGMTString method:

d = new Date();
s = "Current setting is ";
s += d.toGMTString();

document.write(s);

To run the code above, paste it into JavaScript Editor, and click the Execute button

See Also: Date Object Methods, toUTCString Method