PHP String Turn time

Source: Internet
Author: User

In peacetime we often need to format the time of a string before using

In PHP, you can use the following methods:

$temp _date = ' 2011-01-09 19:25:43 ';

Date (' y-m-d ', Strtotime ($temp _date)); The output of this is 2011-01-09.

The function of Strtotime is to resolve the date-time description of any English text to a UNIX timestamp

The following is an official note:

int strtotime (string time [, int now])
This function expects to accept a string that contains the English date format and attempts to resolve it to a UNIX timestamp. The now parameter does not work if the time is in absolute times format.

If time is in a relative time format, it is provided by now, or the current time is not available if the?? Returns-1 when failed.

Programs are more robust, then we can determine if we can convert

It also needs to be explained that there is a time interval: December 13, 1901 Friday 20:45:54 to January 19, 2038 Tuesday 03:14:07

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.