How to obtain PHP day of the week

Source: Internet
Author: User

I have been learning PHP for a long time. I would like to share my little experience with you here. PHP is a server scripting language used to create dynamic web pages. Like ASP and ColdFusion, users can use PHP and HTML to write WEB pages. When a visitor browses this page, the server first processes the PHP commands on the page, then, the processed results and HTML content are sent to the browser at the access end.

However, unlike ASP or ColdFusion, PHP is an open source code program with good cross-platform compatibility. You can run PHP on Windows NT and many versions of Unix systems, and run PHP as a built-in module of the Apache server or CGI program. In addition to precisely controlling the content displayed on the web page, you can also use PHP to send HTTP headers. Users can set cookies through PHP, manage user identification, and redirect user browsing pages. PHP has very powerful database support functions and can access almost all of the more popular database systems. In addition, PHP can be integrated with multiple external libraries to provide users with more practical functions, such as generating PDF files.

You can directly enter the PHP Command code on the WEB page without any special development environment. On the WEB page, all PHP code is placed in "<? Php "and"?>" . In addition, you can also select a format such as <script language = "php"> </SCRIPT>. The PHP engine automatically identifies and processes all code on the page between PHP delimiters. The syntax structure of PHP script is very similar to that of C and Perl. You do not need to declare variables before using them. Using PHP to create an array is also very simple. PHP also has basic object-oriented component functions, which greatly facilitates users to effectively organize and encapsulate their own code. Today, I want to introduce how to obtain PHP in a day of the week.

PHP day of the week to get the code:

 
 
  1. Date ("l ");
  2. // Data can be used to obtain the English week, such as Sunday.
  3. Date ("w ");
  4. // You can obtain the number of weeks, for example, 123. Note that 0 is Sunday.

You can obtain the Chinese Week.

 
 
  1. $Weekarray= Array ("day", "one", "two", "three", "four", "five", "Six ");
  2. Echo "Week". $ weekarray [date ("w")];

Obtain the specified date:

 
 
  1. $Weekarray= Array ("day", "one", "two", "three", "four", "five", "Six ");
  2. Echo "Week". $ weekarray [date ("w", "2011-11-11")];

Because the date function is very powerful, he is fully qualified for all such work. I have attached a table in the manual.

 
 
  1. A-"am" or "pm"
  2. A-"AM" or "PM"
  3. D-a few days, two digits. If there are less than two digits, fill in the first zero. For example, "01" to "31"
  4. D-the day of the week, with three English letters, for example, "Fri"
  5. F-month, full English name; for example: "January"
  6. H-12 hours, for example, "01" to "12"
  7. H-24 hours, for example, "00" to "23"
  8. Hours in the g-12 hour format. Less than two hours do not fill in zero. For example: "1" to 12"
  9. Hours in the G-24-hour format. Less than two hours do not fill in zero. For example: "0" to "23"
  10. I-minutes; for example: "00" to "59"
  11. J-a few days, two digits. If less than two digits are left blank, for example, "1" to "31"
  12. L-the day of the week, full name in English; for example: "Friday"
  13. M-month, two digits. If there are less than two digits, add zero in front, for example, "01" to "12"
  14. N-month, two digits. If less than two digits are left blank, for example, "1" to "12"
  15. M-month, with three English letters, for example, "Jan"
  16. S-seconds; for example: "00" to "59"
  17. The end of the S-character is followed by an English sequence, with two English letters, for example, "th", "nd"
  18. T-specifies the number of days in a month, for example, "28" to "31"
  19. U-total seconds
  20. W-number of weeks, for example, "0" (Sunday) to "6" (Saturday)
  21. Y-year, four digits, such as: "1999"
  22. Y-year, two digits, for example, "99"
  23. Z-the day of the year, for example, "0" to "365"

The above describes in detail how to obtain the PHP day of the week and the date function. Please try it.


Related Article

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.