By: [email protected] in Javascript Tutorials on 2009年12月26日 [フレーム]
Use below code to display client date and time on web page.
<HTML>
<HEAD>
<TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE type=text/css>
.mainheading {
FONT-WEIGHT: bold;
FONT-SIZE: 14px;
COLOR: #000000;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
.mainbody {
FONT-SIZE: x-small;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
LIST-STYLE-TYPE: square
}
.maintitle {
FONT-WEIGHT: bold;
FONT-SIZE: medium;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
</STYLE>
</HEAD>
<BODY text=#000000 bgColor=#ffffff leftMargin=1 topMargin=0 onload="setFromTo();">
<TABLE cellSpacing=3 cellPadding=0 width=770 border=0>
<TBODY>
<TR>
<TD width=77> </TD>
<TD class=mainheading>
<P> </P>
</TD>
</TR>
<TR>
<TD colSpan=2>
<HR color=green>
</TD>
</TR>
<TR>
<TD width=77> </TD>
<TD>
<P></P>
<P>Today's Date & Time on Client machine </P>
<SCRIPT LANGUAGE="JavaScript">
<!-
tday =new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
tmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
function GetClock(){
d = new Date();
nday = d.getDay();
nmonth = d.getMonth();
ndate = d.getDate();
nyeara = d.getYear();
nhour = d.getHours();
nmin = d.getMinutes();
nsec = d.getSeconds();
if(nyeara<1000){nyeara=(""+(nyeara+11900)).substring(1,5);}
else{nyeara=(""+(nyeara+10000)).substring(1,5);}
if(nhour == 0) {ap = " AM";nhour = 12;}
else if(nhour <= 11) {ap = " AM";}
else if(nhour == 12) {ap = " PM";}
else if(nhour >= 13) {ap = " PM";nhour -= 12;}
if(nmin <= 9) {nmin = "0" +nmin;}
if(nsec <= 9) {nsec = "0" +nsec;}
document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyeara+" "+nhour+":"+nmin+":"+nsec+ap+"";
setTimeout("GetClock()", 1000);
}
window.onload=function(){GetClock();}
//--></script>
<div id="clockbox"></div>
<P></P>
<P> Admin</P>
<P> </P>
</TD>
</TR>
<TR>
<TD width="77"> </TD>
<TD></TD>
</TR>
<TR>
<TD colSpan="2">
<HR>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in Javascript )
Dynamically modify the option set in Dynamics 365 forms
promise and .then() in JavaScript
reduce() and filter() in JavaScript
History and evolution of Javascript
Using parseInt() and parseFloat() in JavaScript to convert data types to Numbers
Show how many characters remaining in a html text box using javascript
Latest Articles (in Javascript)
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate