Use details and differences between php time and date, and use details of date

Source: Internet
Author: User

Use details and differences between php time and date, and use details of date

Use difference between php time and date

1. time () function

The time () function in PHP uses the echo output to display a very long integer, which contains the date and time, which is a calculated value. To obtain a date format like Y-m-d H: I: s, you can use the date method:

Date ('Y-m-d H: I: s', time ());

Echo output it to get: 10:20:11

2. Date Format and string

We can build a date string, for example, 10:20:11. You can use the strtotime () function to convert the string into a value in time format. For example:

$ Time1 = strtotime ('2017-1-5 10:20:11 ');

Returns a long integer from the echo output.

Therefore, it can be understood as follows:

  1. The date is saved as a long integer in php. It can be converted to the date type through the date function, and the date type can directly output strings.
  2. You can use the strtotime () function to convert a date string to the time format (a long integer ).
  3. Date Format. You can use int to forcibly convert the data type and convert the data to an integer.

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

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.