Source: http://www.ido321.com/847.html
In the project you need a timer, the effect is as follows:
JS Code
1:/* Get current time * /
2:function getcurrentdate ()
3: {
4: ";
5: new Date ();
6: var curmonth = Curdate.getmonth () +1; //Get the current month (0-11, 0 for January)
7: var curday = Curdate.getdate (); //Get current day (1-31)
8: var curweekday = Curdate.getday (); //Get Current week x (0-6, 0 for Sunday)
9: var curhour = curdate.gethours (); //Get current hours (0-23)
£ º var curminute = Curdate.getminutes (); //Gets the current number of minutes (0-59)
One: var cursec =curdate.getseconds (); //Gets the current number of seconds (0-59)
: timestr = curmonth+' month ' +curday+' Day week ';
: switch (curweekday)
: {
: ' Day '; break;
: ' one '; break;
: ' two '; break;
: ' three '; break;
: ' four '; break;
: ' five '; break;
: ' VI '; break;
: }
Max: if (Curhour < ten)
: {
: if (Curminute < ten)
: {
: if (Cursec < ten)
: {
: ' 0 ' +curhour+': 0 ' +curminute+': 0 ' +cursec;
: }
To: Else
: {
: ' 0 ' +curhour+': 0 ' +curminute+': ' +cursec;
: }
: }
$: Else
PNS: {
Max: if (Cursec < ten)
The following: {
Max: ' 0 ' +curhour+': ' +curminute+': 0 ' +cursec;
In: }
: Else
: {
: ' 0 ' +curhour+': ' +curminute+': ' +cursec;
: }
: }
: }
To: Else
$: {
: if (Curminute < ten)
Wuyi: {
: if (Cursec < ten)
: {
Si: ' +curhour+': 0 ' +curminute+': 0 ' +cursec;
: }
$: Else
: {
: ' +curhour+': 0 ' +curminute+ ':' +cursec;
: }
: }
I: Else
+: {
: if (Cursec < ten)
: {
: ' +curhour+': ' +curminute+': 0 ' +cursec;
: }
: Else
: {
" +curhour+': ' +curminute+ ': '+cursec;
: }
: }
: }
: $ ("#time"). Text (timestr);
A: }
Then the bar uses this function to line up.
Finally, a summary of some of the functions of the JavaScript date:
var mydate = new Date ();
Mydate.getyear (); Get Current year (2-bit)
Mydate.getfullyear (); Get the full year (4-bit, 1970-????)
Mydate.getmonth (); Get the current month (0-11, 0 for January)
Mydate.getdate (); Get current day (1-31)
Mydate.getday (); Get Current week x (0-6, 0 for Sunday)
Mydate.gettime (); Gets the current time (the number of milliseconds since 1970.1.1)
Mydate.gethours (); Get current number of hours (0-23)
Mydate.getminutes (); Gets the current number of minutes (0-59)
Mydate.getseconds (); Gets the current number of seconds (0-59)
Mydate.getmilliseconds (); Gets the current number of milliseconds (0-999)
Mydate.tolocaledatestring (); Get Current date
var mytime=mydate.tolocaletimestring (); Get current time
Mydate.tolocalestring (); Get Date and time
JavaScript Time Operations Summary