Web site more user-friendly---Let PHP judge time and week

Source: Internet
Author: User
Tags php website

Program humanization, Web site humanization, is the pursuit of programmers, such as the design of PHP website, in the page to add a piece of such code, may be more humane. take advantage of PHP's simple judgment and read a little gadget written at the current time. It's boring, but it feels good.

Add a user-friendly reminder with the following code:

<?php date_default_timezone_set (' PRC ');   Set China time zone if (0<=date (' h ') && date (' h ') <7) {    echo "Good morning! Late at night, rest early! ";} if (7<=date (' h ') && date (' h ') <12) {    echo "Good morning! A good day has begun, come on. ";} if (12<=date (' h ')  && date (' h ') <16) {    echo "Good afternoon! Have a cup of afternoon tea for a rest. ";} if (16<=date (' h ')  && date (' h ') <19) {    echo "Good afternoon! Have a good time in the afternoon. ";} if (19<=date (' h ') && date (' h ') <21) {    echo "Good evening! It's time to relax after dinner. ";} if (21<=date (' h ') && date (' h ') <23) {    echo "Good evening! What have you learned from the busy day? ";}? >

Get current time, week

<?php $atime =date ("Y year M D Day"); $week = Array (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday); Echo $atime; echo $week [Date (w)];? >
OK, you can upload it.

Web site more user-friendly---Let PHP judge time and week

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.