The PHP date () function formats the timestamp as a more readable date and time.
The
Syntax date (format,timestamp) parameter describes the format required. Specify the format of the timestamp. Timestamp optional. Specify a timestamp. The default is the current date and time. PHP Date-What is a timestamp (Timestamp)?
The timestamp is the number of seconds since January 1, 1970 (unlimited GMT). It is also known as the Unix timestamp (Unix Timestamp).
PHP Date-format Date
The first parameter of the date () function prescribes how the date/time is formatted. It uses letters to indicate the format of dates and times. Here are some of the letters available:
D-Day of the month (01-31) m-Current month, in Digital (01-12) Y-current year (four digits)
You can find all the letters available in the format parameters in our PHP Date reference manual.
You can insert other characters between letters, such as "/", "." or "-", so you can add additional formatting:
<?php echo Date ("y/m/d"); echo "<br/>"; echo Date ("Y.M.D"); echo "<br/>"; echo Date ("y-m-d");?>
The second parameter of the date () function sets a timestamp. This parameter is optional. If you do not provide a timestamp, the current time will be used.
In our example, we'll use the Mktime () function to create a timestamp for tomorrow.
The Mktime () function returns the Unix timestamp for the specified date.
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.