Date functions of PHP series Learning

Source: Internet
Author: User

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.

 
  1. <!DOCTYPE html> 
  2.     <meta charset="utf-8" /> 
  3.     <title>Getting started with dates in php5</title> 
  4. <body> 
  5. <?php 
  6. date_default_timezone_set('Asia/Shanghai');  
  7. echo "Today is ",date('l');  
  8. ?> 
  9. </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

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.