Definition and Usage The toTimeString() method returns the time portion of a Date object in readable form. Syntax dateObject.toTime...
Definition and Usage
The toTimeString() method returns the time portion of a Date object in readable form.
Syntax
dateObject.toTimeString() |
Example 1
In the example below we will return the time portion of today's date:
<script type="text/javascript"> var d = new Date();
document.write(d.toTimeString()); </script> |
The output of the code above will be:
14:36:53 GMT+0530 (India Standard Time) |
Example 2
In the example below we will return the time portion of a specific date:
<script type="text/javascript"> var x = new Date("July 21, 1983 01:15:00");
document.write(x.toTimeString()); </script> |
The output of the code above will be:
01:15:00 GMT+0530 (India Standard Time) |