CoffeeScript Date - toTimeString()



Description

The toTimeString() method returns the time portion of a Date object in human readable form.

Syntax

Given below is the syntax of toTimeString() method.

Date.toTimeString()

Return Value

Returns the time portion of a Date object in human readable form.

Example

The following example demonstrates the usage of the toTimeString() method in CoffeeScript. Save this code in a file with name date_totimestring .coffee.

dt = new Date(1993, 6, 28, 14, 39, 7);
console.log dt.toTimeString() 

Open the command prompt and compile the .coffee file as shown below.

c:\> coffee -c date_totimestring .coffee

On compiling, it gives you the following JavaScript.

// Generated by CoffeeScript 1.10.0
(function() {
  var dt;

  dt = new Date(1993, 6, 28, 14, 39, 7);

  console.log(dt.toTimeString());

}).call(this);

Now, open the command prompt again, and run the CoffeeScript file as shown below.

c:\> coffee date_totimestring.coffee

On executing, the CoffeeScript file produces the following output.

14:39:07 GMT+0530 (India Standard Time)
coffeescript_date.htm
Advertisements