Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/05/2011, 09:46
Avatar de _cronos2
_cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 11 meses
Puntos: 310
Respuesta: formato RFC822 con javascript

Eso pasa porque estás asignando a la variable una referencia a la función, y no lo que devuelve la función. Puedes reducir el código a esto:
Código Javascript:
Ver original
  1. function mostrarFecha(tiempo){
  2.  var fecha = new Date(tiempo || +new Date()), str = '';
  3.  var equiv = {
  4.   dias : ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
  5.   meses : ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
  6.  };
  7.  str += equiv.dias[fecha.getDay()] + ', ' + fecha.getDate() + ' de ';
  8.  str += equiv.meses[fecha.getMonth()] + ' de ' + fecha.getFullYear();
  9.  str += ', ' + fecha.getHours + ':' +  fecha.getMinutes +  fecha.getSecond;
  10.  return str;
  11. }
  12.  
  13. var fecha1 = mostrarFecha(); // sábado, 28 de mayo de 2011, 17:45:25
  14. var fecha2 = mostrarFecha(0); // jueves, 1 de enero de 1970, 0:0:0
Saludos (:
__________________
" Getting older’s not been on my plans
but it’s never late, it’s never late enough for me to stay. "
Cigarettes - Russian Red