EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
PF Preguntas - Foro

Obtener el año actual en Javascript

¿Cómo obtengo el año actual en 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 preguntó hace 7 años
1 Respuestas

Muy simple. Crea un objeto de tipo Date() y llama al 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
Pedro Tizón respondió hace 7 años