EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
Definir como idioma padrão
Perguntas de PF - Fórum

Obter o ano atual em Javascript

Como obtenho o ano atual em Javascript?

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
juanma21 Será que perguntou 7 anos
1 Respostas

Muito simples. Cria um objeto do tipo Dar-lhe() e chama o método getFullYear()

var fecha = new Date();
var anyo = fecha.getFullYear();

//o de forma más simple
var anyo = new Date().getFullYear();

 

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
Ferrugem de Peter disse faz 7 anos