CoffeeScript Date - getUTCFullYear ()

Descrizione

Il getUTCFullYear()restituisce l'anno nella data specificata in base all'ora universale. Il valore restituito da getUTCFullYear () è un numero assoluto conforme all'anno 2000, ad esempio 2008.

Sintassi

Di seguito è riportata la sintassi di getUTCFullYear() metodo.

Date.getUTCFullYear()

Esempio

L'esempio seguente mostra l'utilizzo di getUTCFullYear()metodo in CoffeeScript. Salva questo codice in un file con nomedate_getutcfullyear.coffee.

dt = new Date "February 19, 2016 23:15:25:22"
console.log "The UTC full year in the specified date is : " + dt.getFullYear()

Apri il command prompt e compila il file .coffee come mostrato di seguito.

c:\> coffee -c date_getutcfullyear.coffee

Durante la compilazione, ti dà il seguente JavaScript.

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

  dt = new Date("February 19, 2016 23:15:25:22");

  console.log("The UTC full year in the specified date is : " + dt.getFullYear());

}).call(this);

Ora apri il file command prompt di nuovo ed eseguire il file CoffeeScript come mostrato di seguito.

c:\> coffee date_getutcfullyear.coffee

All'esecuzione, il file CoffeeScript produce il seguente output.

The UTC full year in the specified date is : 2016