Ejemplos en Javascript

Fecha y hora

Fecha y horario desde formulario TEXT

<HTML>
<HEAD>

<TITLE>Ejemplos Javascript: ejemplo pr???¡ctico </TITLE>

<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- Begin Digital Watch
document.write('<!-- Begin Hiding Script -->')
/*
######################################################################
################       SCRIPT BY BURNBLADE       #####################
################         Visit My Site At        #####################
################      http://www.burning.net     #####################
################         ????© copywrite 1997        #####################
######################################################################
  This script may be used as long as the above lines are not changed
                             in any way.
*/
var watchID = null
var watchRun = false
function stopwatch(){
  if(watchRun)
    clearTimeout(watchID)
  watchRun = false
}
function startwatch(){
  stopwatch()
  dayTime()
}

function dayTime() {
  day = new Date();
  hour = day.getHours();
  minute = day.getMinutes();
  second = day.getSeconds();
 
  if (hour > 12) {
  hours = hour - 12;
  part = 'PM'}
  else {
  part = 'AM';
  if (hour == 0) {
  hours = 12
  }
  else {
  hours = hour
  }
  }
  if (minute < 10) {minutes = 0}
  else {minutes = ""}
  if (second < 10) {seconds = 0}
  else {seconds =""}
  date = ('' +(day.getMonth() + 1)+"/"+day.getDate()+ "/"+day.getYear()+ '');
  time = ('' + hours + ":"+minutes+""+minute+ ":"+seconds+""+second+ '')
  parts = ('' +part+ '')
  document.timedate.time.value = time
  document.timedate.date.value = date
  document.timedate.parts.value = parts
  watchID = setTimeout("dayTime()",1000)
  watchRun = true
}
document.write('<!-- End Hiding Script -->')
// End Digital Watch-->
</script>

</HEAD>

<BODY bgcolor="white"  onLoad="startwatch()">


<form name="timedate" onSubmit="0">
<table cellspacing=0 cellpadding=0>
<tr align=center>
 <td><INPUT TYPE="text" NAME="time" SIZE=7 VALUE ="..Starti"></td>
 <td><INPUT TYPE="text" NAME="parts" SIZE=2 VALUE ="ng.."></td>
</tr>
<tr align=center>
 <td colspan=2><INPUT TYPE="text" NAME="date" SIZE=8 VALUE ="........"></td>
</tr>
</table>
</form></CENTER>



</body>
</html>

Fechas y horarios