SoloCodigo
Programación Web y Scripting => JavaScript => Mensaje iniciado por: emmprune en Jueves 21 de Junio de 2007, 00:58
-
Hola a todos
Disculpen tengo el siguiente problema. Necesito obtener el número de semana de determinada fecha, alguien me podría decir si existe un comando o función que calcule eso...o donde podría leer mas al respecto, ya que en los tutoriales que he leido no he encontrado nada.
Muchas gracias por su tiempo!!
-
Buscar por aquí: GregorianCalendar (http://www.google.com/search?q=GregorianCalendar)
Puede que haya una librería para JS.
Luis Javier López Arredondo
-
Muchas gracias por responder... voy a consultarlo y te comento.
-
bueno, checa este link, espero te sirva
http://www.manualdephp.com/manualphp/fechas.html (http://www.manualdephp.com/manualphp/fechas.html)
saludos
-
Hola... muchas gracias por sus repuestas. Encontre esta función en : www.quirksmode.org/js/week.html (http://www.quirksmode.org/js/week.html)
function getWeekNr()
{
var today = new Date();
Year = takeYear(today);
Month = today.getMonth();
Day = today.getDate();
now = Date.UTC(Year,Month,Day+1,0,0,0);
var Firstday = new Date();
Firstday.setYear(Year);
Firstday.setMonth(0);
Firstday.setDate(1);
then = Date.UTC(Year,0,1,0,0,0);
var Compensation = Firstday.getDay();
if (Compensation > 3) Compensation -= 4;
else Compensation += 3;
NumberOfWeek = Math.round((((now-then)/86400000)+Compensation)/7);
return NumberOfWeek;
}
function takeYear(theDate)
{
x = theDate.getYear();
var y = x % 100;
y += (y < 38) ? 2000 : 1900;
return y;
}
Por si a alguien le es util. Solo se tiene que modificar un poco para acoplarla a las necesidades de cada quien. Por ejemplo se puede reemplazar la función takeYear() con un getFullYear().
Saludos!!