PHP display time. How can this problem be solved? If statement may be incorrect

Source: Internet
Author: User
The PHP display time is incorrect. What should I do? If statement may be incorrect. I want this link to be between and am. Display the address www.97find.cn & nbsp; and display the address www.vipcha.net & nbsp at other times. I use & lt ;? Phpecho & quot; h = & qu the PHP display time is incorrect. What should I do? If statement may be incorrect.
I want this link to be between and am. Display this address www.97find.cn
Then display www.vipcha.net at other times

Now both are displayed.
I use
01 displayed at 1 point


If (date ('h')> = 16 | date ('h') <= 22 ){
?>
Convenient tools

} Else {
Convenient tools
}
?>



------ Solution --------------------
Php Manual
G-hour, 12-hour format, no leading zero 1 to 12
G-hour, in 24-hour format, no leading 0 to 23
H-hour, 12-hour format, with a leading value of 0 to 12
H-Hour, in 24-hour format, with a leading zero 00 to 23

Conversion

Echo intval ('03 ');
Echo (int) ('03 ');
------ Solution --------------------
} Else {
Echo "convenient tools ";
}
?>

------ Solution --------------------
If (date ('h')> = 1 & date ('h') <= 5 ){
------ Solution --------------------
In this case, do I have to refresh the page? No side php only runs once. how can you obtain the later time of your date value.
Therefore, I personally suggest using JavaScript:
[Dynamic time] you can add your url in timetip.
HTML code
Script window. onload = running; // run the running () function running () {timeshow () ;}function addzero (param) {var str = ""; if (param <10) str = "0" + param; else str = param; return str;} function timeshow () {var today = new Date (); var y = today. getFullYear (); var m = today. getMonth () + 1; // when the hour is taken out, + 1 var d = today. getDate (); var h = today. getHours (); var I = today. getMinutes (); var s = today. getSeconds (); var a = today. getDay (); var week = ""; switch (a) {case 0: week = "Sunday"; break; case 1: week = "Monday"; break; case 2: week = "Tuesday"; break; case 3: week = "week"; break; case 4: week = "Thursday"; break; case 5: week = "Friday "; break; case 6: week = "Saturday"; break;} // determine the current time period [color = # FF0000] var timetip = ""; if (h <12) {// alert (h); if (h> 6) {timetip = "morning";} else if (h> 0 & h <6) | h = 6 | h = 0) {timetip = "morning";} // end if} else if (h = 12) {timetip = "noon" ;}else {if (h> 12 & h <18) {timetip = "afternoon ";} else if (h> 18 & h <24) | h = 18) {timetip = "evening ";} // end if} // end if [/color] m = addzero (m); d = addzero (d); h = addzero (h ); I = addzero (I); s = addzero (s ); var riqi = week + "" + y + "year" + m + "month" + d + "day" + ""; // assign the year, month, day, and week to the riqi variable var sfm = h + ":" + I + ":" + s; // assign the hour, minute, and second value to the sfm variable [color = # FF0000] var sp = document. getElementById ("showtime"); // gets the object SPNS of the location to be placed. innerHTML = riqi + y + "-" + m + "-" + d + "" + sfm; // put the time in the page [/color] setTimeout ("timeshow () ", 1000); // runs the timesho () function once every one second} script

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.