|
| JAVASCRIPT toGMTString() METHOD
The toGMTString() method in javascript converts a date object into GMT (Greenwhich Mean Time) Time and returns the result as a string.
The general format is:
dateObject.toGMTString(specified date[optional]);
The toGMTString()method takes an optional specified date as parameter. If left out, today's date will be used.
If you want to return the full date/time with the toGMTString()method, you will first have to create a new date object and then use the new date object with the toGMTString()method.
Example 1: Return date/time string as of now.
<script type="text/javascript">
var dd = new Date(); //sets the date/time
document.write (dd.toGMTString()); //outputs the date/time
</script>
Will output:
Example 2: Return date/time string with a specified date/time.
<script type="text/javascript">
var dd = new Date("May 21, 2007 01:15:00");
document.write (dd.toGMTString());
</script>
Will output:
See Also:
|
|