Original eco-JavaScript get date
Copy Code code as follows:
<script language= "JavaScript" >
var mydate = new Date ();
Mydate.getyear (); Get Current year (2-bit)
Mydate.getfullyear (); Get full year (4-bit, 1970-????)
Mydate.getmonth (); Get Current month (0-11, 0 for January)
Mydate.getdate (); Get the current day (1-31)
Mydate.getday (); Get Current week x (0-6, 0 for Sunday)
Mydate.gettime (); Gets the current time (number of milliseconds since 1970.1.1)
Mydate.gethours (); Get the current number of hours (0-23)
Mydate.getminutes (); Get the current number of minutes (0-59)
Mydate.getseconds (); Get the current number of seconds (0-59)
Mydate.getmilliseconds (); Get current number of milliseconds (0-999)
Mydate.tolocaledatestring (); Get Current date
var mytime=mydate.tolocaletimestring (); Get current time
Mydate.tolocalestring (); Get Date and time
if (mytime< "23:30:00")
{
alert (mytime);
}
</SCRIPT>
Get date based on jquery
Copy Code code as follows:
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> Current Time </title>
<script src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type= "Text/javascript" ></ Script>
<style type= "Text/css" >
. date{height:100px;line-height:100px;margin:0 auto;font-family:arial, Helvetica, sans-serif;font-size:40px;
Border:solid 1px #ccc; box-shadow:0 0 3px Rgba (0,0,0,0.3) inset;border-radius:5px;text-shadow:1px 1px 2px rgba (0,0,0,0.3);
. Date strong{padding:0 10px;display:inline-block;height:100px;border-right:solid 1px #ccc;}
</style>
<body>
<p class= "Date" >
<strong id= "Y" ></strong>
<strong id= "MH" ></strong>
<strong id= "TD" ></strong>
<strong id= "D" ></strong>
<strong id= "H" ></strong>
<strong id= "M" ></strong>
<strong id= "S" ></strong>
</p>
<script type= "Text/javascript" >
$ (document). Ready (function () {
SetInterval (showTime, 1000);
function Timer (obj,txt) {
Obj.text (TXT);
}
function ShowTime () {
var today = new Date ();
var weekday=new Array (7)
weekday[0]= "Monday"
weekday[1]= "Tuesday"
weekday[2]= "Wednesday"
weekday[3]= "Thursday"
weekday[4]= "Friday"
weekday[5]= "Saturday"
weekday[6]= "Sunday"
var y=today.getfullyear () + "year";
var month=today.getmonth () + "month";
var td=today.getdate () + "Day";
var d=weekday[today.getday ()];
var h=today.gethours ();
var m=today.getminutes ();
var s=today.getseconds ();
Timer ($ ("#Y"), Y);
Timer ($ ("#MH"), month);
Timer ($ ("#TD"), TD);
Timer ($ ("#D"), D);
Timer ($ ("#H"), H);
Timer ($ ("#M"), M);
Timer ($ ("#S"), S);
}
})
</script>
</body>
Good morning code.
Copy Code code as follows:
<script language= "JavaScript" >
Define a tick function to get the time of the system
function tick ()
{
var Year,month,day,hours,minutes,seconds,ap;
var intyear,intmonth,intday,inthours,intminutes,intseconds;
var today;
Today=new Date ();
Intyear=today.getyear ();
Intmonth=today.getmonth () +1;
Intday=today.getdate ();
Inthours=today.gethours ();
Intminutes=today.getminutes ();
Intseconds=today.getseconds ();
Number of hours to get system time
if (inthours==0)
{
hours=inthours+ ":";
ap= "Early Morning";
}
else if (inthours<12)
{
hours=inthours+ ":";
Ap= "Morning";
}
else if (inthours==12)
{
hours=inthours+ ":";
Ap= "Noon";
}
Else
{
inthours=inthours-12;
hours=inthours+ ":";
Ap= "Afternoon";
}
Gets the score of the system time
if (intminutes<10)
{
minutes= "0" +intminutes+ ":";
}
Else
minutes=intminutes+ ":";
Number of seconds to get system time
if (intseconds<10)
seconds= "0" +intseconds+ "";
Else
Seconds=intseconds+ "";
Timestring=year+month+day+hours+minutes+seconds+ap;
clock.innerhtml=timestring;
Perform a tick function every 0.1 seconds
Window.settimeout ("tick ()", 100);
}
Window.onload=tick;
</script>
The following sentence is called the function
<div id= "Clock" ></div>