Current Date & Time Script_Ngày giờ hiển thị theo dạng bảng

rongcon

Công Thần CTIT
PHP:
<head>
<!--This script downloaded from CongTruongIT.Com --> 
<script language="JavaScript">
var showDateShort = 1;
var showDate= 2;
var showDateTime= 3;
var showTime= 4;

function ShowDateTime(dateStyle)
{
	var today = new Date();
	var dStr = "";
	
	switch (dateStyle)
	{
		case showDateShort:
			dStr = today.toDateString();
			break;
		case showDateTime:
			dStr = today.toLocaleString();
			break;
		case showTime:
			dStr = today.toLocaleTimeString();
			break;
		case showDate:
		default:
			dStr = today.toLocaleDateString();
			break;
	}
	document.write(dStr);
}

</script>
</head>

<body>
<font face="verdana, geneva, helvetica" size=2>
<table style="BORDER-COLLAPSE: collapse" bordercolor=#111111 cellspacing=0 cellpadding=4 border=1>
  <tr> 
    <td><i><b><font size=2>dateStyle</font></b></i></td>
    <td><font size=2><b>E</b></font><b><font 
                        size=2>xample</font></b></td>
  </tr>
  <tr> 
    <td><font size=2>showDateShort</font></td>
    <td><font size=2> 
      <script language=JavaScript>ShowDateTime(showDateShort)</script>
      </font>&nbsp;</td>
  </tr>
  <tr> 
    <td><font size=2>showDate</font></td>
    <td><font face="verdana, geneva, helvetica" size=2> 
      <script language=JavaScript>ShowDateTime(showDate)</script>
      </font>&nbsp;</td>
  </tr>
  <tr> 
    <td><font size=2>showDateTime</font></td>
    <td><font face="verdana, geneva, helvetica" size=2> 
      <script language=JavaScript>ShowDateTime(showDateTime)</script>
      </font>&nbsp;</td>
  </tr>
  <tr> 
    <td><font size=2>showTime</font></td>
    <td><font face="verdana, geneva, helvetica" size=2> 
      <script language=JavaScript>ShowDateTime(showTime)</script>
      </font>&nbsp;</td>
  </tr>
</table>
</font> 
</body>
</html>
DEMO

 
Top