Real-time PHP implementation

Source: Internet
Author: User

<Body>
<Script language = "Javascript">
<! --
Document. write ('<div id = "Today"> </div> ');
Var a = 0;
Var Y = [color = # FF0000] <? Echo date ('Y')?> [/Color], M = [color = # FF0000] <? Echo date ('N')?> [/Color], D = [color = # FF0000] <? Echo date ('J')?> [/Color];
Function clock (){
Sec = [color = # FF0000] <? Echo strtotime ('8 hours')?> [/Color] a; // (GMT) time zone: China Standard Time
S = sec '; // second
I = Math. floor (sec/60) '; // minute
H = Math. floor (sec/3600) $; // Hour
W = '2014, 4, 6, 1, 2, 3 '. charAt (Math. floor (sec/86400) % 7); // day of the week
If (S <10) S = '0' S;
If (I <10) I = '0' I;
If (H <10) H = '0' H;
If (H = '00' & I = '00' & S = '00') D = D 1; // daily input
If (M = 2) {// determines whether it is July ******
If (! Y % 4> 0) {// It is a leap year (28 days on January 1, February)
If (D = 30) {M = 1; D = 1;} // carry the month
}
Else {// non-leap year (29 days from January 1, February)
If (D = 29) {M = 1; D = 1 ;}// carry the month
}
}
Else {// not the month of February ******
If (M = 4 | M = 6 | M = 9 | M = 11) {// small month (30 days)
If (D = 31) {M = 1; D = 1;} // carry the month
}
Else {// Large month (31 days)
If (D = 32) {M = 1; D = 1;} // carry the month
}
}
If (M = 13) {Y = 1; M = 1;} // year carry
TimeStr = Y 'M', 'D', 'D', 'Wed', 'H': 'I': 'S;
Today. innerHTML = timeStr;
A;
}
Clock (); // This line can be left blank, only for initialization...
SetInterval (clock, 1000 );
// -->
// The rule for determining a leap year is that it can be fully divided by four, but can be fully divided by 100 instead of a leap year, and can be fully divided by 400 into a leap year.
// For example, 1600, 2000, and 2400 are leap years, while 1700, 1800, 1900, and 2100 are flat years (non-leap years)
// PHP can only process the time range of 100-400 years at present, so ignore the division events of and.
</Script>
</Body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.