Ejemplos en Javascript
Fecha y hora en la barra de estado con botones
Este script permite controlar fecha y hora en la barra de estado del navegador gracias a tres botones.
<HTML>
<HEAD>
<TITLE>Ejemplos Javascript: ejemplo prÃ?Æ?Ã?¡ctico </TITLE>
<SCRIPT>
<!-- Activate Cloaking Device
//********************************************************************
//
// Date & Time Display on the Status Bar
//
// Developed by Timothy Wallace , timothy@essex1.com
//
//********************************************************************
// Global variables for timer.
var timerID = null;
var timerRunning = false;
// Called by both onLoad in BODY tag, and Resume button.
function startclock ()
{
// Make sure the clock is stopped
stopclock();
time();
}
// Kills clock.
function stopclock ()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function time ()
{
var now = new Date();
var yr = now.getYear();
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1;
var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
var ampm = (now.getHours() >
= 12) ? " P.M." : " A.M."
var hours = now.getHours();
hours = ((hours > 12) ? hours - 12 : hours);
var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
if(dName==1) Day = "Domingo";
if(dName==2) Day = "Lunes";
if(dName==3) Day = "Martes";
if(dName==4) Day = "MiÃ?Æ?Ã?©rcoles";
if(dName==5) Day = "Jueves";
if(dName==6) Day = "Viernes";
if(dName==7) Day = "SÃ?Æ?Ã?¡bado";
if(mName==1) Month="Enero";
if(mName==2) Month="Febrero";
if(mName==3) Month="Marzo";
if(mName==4) Month="Abril";
if(mName==5) Month="Mayo";
if(mName==6) Month="Junio";
if(mName==7) Month="Julio";
if(mName==8) Month="Agosto";
if(mName==9) Month="Septiembre";
if(mName==10) Month="Octubre";
if(mName==11) Month="Noviembre";
if(mName==12) Month="Diciembre";
// String to display current date.
var DayDateTime=(" "
+ Day
+ " "
+ Month
+ " "
+ dayNr
+ ", "
+ "19"
+ yr
+ " "
+ hours
+ minutes
+ seconds
+ " "
+ ampm
);
// Displays Day-Date-Time on the staus bar.
window.status=DayDateTime;
timerID = setTimeout("time()",1000);
timerRunning = true;
}
// Stops clock and clears status bar.
function clearStatus()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
window.status=" ";
}
// Used for View Source
function WinOpen()
{
alert('nPage will load to full screen.nnUse View/Document Source from menu bar to view source.nnClose new window to return to this page. ');
window.open("js-statc.htm","DisplayWindow","menubar=yes,status=yes");
window.open("js-statc.htm","DisplayWindow","menubar=yes,status=yes"); // double call for Macs
}
// Deactivate Cloaking -->
</SCRIPT>
</HEAD>
<BODY bgcolor="white" onLoad="startclock ()">
<form>
<TABLE BORDER=0 WIDTH=350>
<TR>
<TD align="center"><INPUT TYPE="button" value="Pausa" onClick="stopclock()">
<TD align="center"><INPUT TYPE="button" value="En marcha" onClick="startclock()">
<TD align="center"><INPUT TYPE="button" value="Elimina" onClick="clearStatus()">
</TR>
</TABLE>
</form>
</body>
</html>
<HEAD>
<TITLE>Ejemplos Javascript: ejemplo prÃ?Æ?Ã?¡ctico </TITLE>
<SCRIPT>
<!-- Activate Cloaking Device
//********************************************************************
//
// Date & Time Display on the Status Bar
//
// Developed by Timothy Wallace , timothy@essex1.com
//
//********************************************************************
// Global variables for timer.
var timerID = null;
var timerRunning = false;
// Called by both onLoad in BODY tag, and Resume button.
function startclock ()
{
// Make sure the clock is stopped
stopclock();
time();
}
// Kills clock.
function stopclock ()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function time ()
{
var now = new Date();
var yr = now.getYear();
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1;
var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
var ampm = (now.getHours() >
= 12) ? " P.M." : " A.M."
var hours = now.getHours();
hours = ((hours > 12) ? hours - 12 : hours);
var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
if(dName==1) Day = "Domingo";
if(dName==2) Day = "Lunes";
if(dName==3) Day = "Martes";
if(dName==4) Day = "MiÃ?Æ?Ã?©rcoles";
if(dName==5) Day = "Jueves";
if(dName==6) Day = "Viernes";
if(dName==7) Day = "SÃ?Æ?Ã?¡bado";
if(mName==1) Month="Enero";
if(mName==2) Month="Febrero";
if(mName==3) Month="Marzo";
if(mName==4) Month="Abril";
if(mName==5) Month="Mayo";
if(mName==6) Month="Junio";
if(mName==7) Month="Julio";
if(mName==8) Month="Agosto";
if(mName==9) Month="Septiembre";
if(mName==10) Month="Octubre";
if(mName==11) Month="Noviembre";
if(mName==12) Month="Diciembre";
// String to display current date.
var DayDateTime=(" "
+ Day
+ " "
+ Month
+ " "
+ dayNr
+ ", "
+ "19"
+ yr
+ " "
+ hours
+ minutes
+ seconds
+ " "
+ ampm
);
// Displays Day-Date-Time on the staus bar.
window.status=DayDateTime;
timerID = setTimeout("time()",1000);
timerRunning = true;
}
// Stops clock and clears status bar.
function clearStatus()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
window.status=" ";
}
// Used for View Source
function WinOpen()
{
alert('nPage will load to full screen.nnUse View/Document Source from menu bar to view source.nnClose new window to return to this page. ');
window.open("js-statc.htm","DisplayWindow","menubar=yes,status=yes");
window.open("js-statc.htm","DisplayWindow","menubar=yes,status=yes"); // double call for Macs
}
// Deactivate Cloaking -->
</SCRIPT>
</HEAD>
<BODY bgcolor="white" onLoad="startclock ()">
<form>
<TABLE BORDER=0 WIDTH=350>
<TR>
<TD align="center"><INPUT TYPE="button" value="Pausa" onClick="stopclock()">
<TD align="center"><INPUT TYPE="button" value="En marcha" onClick="startclock()">
<TD align="center"><INPUT TYPE="button" value="Elimina" onClick="clearStatus()">
</TR>
</TABLE>
</form>
</body>
</html>
Fechas y horarios
- Fecha última modificación
- Qué hora es 1/2
- Qué hora es 2/2
- Fecha, hora y días transcurridos desde el inicio del año
- Día, hora y fecha pero sólo si se piden
- Horario en la barra de estado del navegador
- Fecha y hora en la barra de estado con botones
- El día de la semana en que naciste
- Tu edad en días, horas, minutos y segundos
- Tiempo y coste de conexión con una página
- Husos horarios del mundo
- Tiempo de acceso a una página
- Horario y tiempo pasado en una página con un botón
- Fecha y hora
- Husos horarios: primer ejemplo
- Saludos, fecha, horario y calendario del mes
- Calendario completo
- Agenda
- Fecha y hora en un alert activado por boton
- Contador con término final
- Cuenta atrás con término final
- Fecha y hora de entrada en una página web
- Husos horarios, secondo esempio
- Tiempo que falta para una cierta fecha
- Última Modificación con variante
- Mensaje según el día de la semana
- Fecha última visita con cookie
- Husos horarios: tercer ejemplo
- Calendario con formulario
- Signos zodiacales
- Recordatorio
- Husos horarios: cuarto ejemplo
- Otro calendario
- Día de la semana a partir de una fecha