Date of PHP () function

Source: Internet
Author: User

Date of PHP () function

PHP's date () function's format timestamp is a more readable date and time.

Grammar

Date (Format,timestamp)
  
  

Parameter description
Format requirements. Timestamp in the specified format
Time Optional. Specifies the time stamp. Default to current date and time (such as time stamp)



PHP Date-format Date
The date () function in the first argument specifies how the date/time is formatted. It uses the letter-represented date and time format. Here are some letters that can be used to:

Buckle-one months of the day (January 3 1st)
M--The current one months, as a number (0 1-12)
Y-year in four digits
An overview of all the letters that can be used for format parameters can be found in our PHP date range.

Other characters, such as "/", ". "or"-"can also be inserted between the letters, add additional formatting:

<?php
echo Date ("y/m/d");
echo "<br/>";
echo Date ("Y.M.D");
echo "<br/>";
echo Date ("y-m-d");
? >
The output is as follows.
2006/07/11
2006.07.11
2006-07-11
 
      
      

PHP Date-add timestamp
the date () function in the second argument specifies a time stamp. This parameter is optional. If you do not provide a time, the current time will be used.

In our next example we will use the Mktime () function to create a time stamp tomorrow.

The Mktime () function returns a UNIX timestamp of a specific date.

Syntax

 mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST) 
   
 
        
        

Go to the future of the day, we just add one day argument mktime ():

<?php
$tomorrow = mktime (0,0,0,date ("M"), date ("D") +1,date ("Y")); echo "Tomorrow is". Date ("y/m/d", $tomorrow);
?

 

 

 

 

The

output is like.

 tomorrow is 2006/07/12 

 

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.