Introduction
PHP is a very surprising language. It is powerful enough (the core language of the largest blog (wordpress) and extensive enough (running on facebook, the largest social networking website). It is simple enough (as the preferred language for beginners ). It runs well on low-cost machines. In addition, php has many very good server suites (such as WAMP and MAMP), which can be conveniently installed on your machine. PHP has a wealth of library resources, which makes it easy for developers to process some businesses. Since we have the most contact with dates in projects, we will start with date functions today.
A simple date example
I will use the echo command to output the content to our client (browser ). I will use the following code as the basic code.
- <!DOCTYPE html>
- <meta charset="utf-8" />
- <title>Getting started with dates in php5</title>
- <body>
- <?php
- date_default_timezone_set('Asia/Shanghai');
- echo "Today is ",date('l');
- ?>
- </body>
You will see the following content in your browser.
Today is Friday
This function outputs the text format of the day of the week. The date function requires at least one character parameter (this parameter tells us how to format the current date ).
Try different formats
If you read the php Manual