Date function in PHP

Source: Internet
Author: User

1, convert to timestamp function: Strtotime ()

This function takes a string containing the U.S. English date format and attempts to resolve it to a Unix timestamp, with a value relative to the time given by the now parameter, and the current time of the system if this parameter is not provided.

<?php/** * Created by Phpstorm. * user:58 * DATE:2016/9/19 * time:15:56 */echo @strtotime ("Now"); Echo ' <br/> '; Echo @strtotime ("September 2015" Echo ' <br/> ', echo @strtotime (' +1 Day '), Echo ' <br/> ', echo @strtotime (' +1 week '); Echo ' <br/> '; echo @  Strtotime (' +1 Week 2 days 4 hours 2 seconds '); Echo ' <br/> '; Echo @strtotime (' next Thursday '); Echo ' <br/> '; echo @strtotime (' last Monday ');

Note: If the given year is a two-digit format, its value of 0-69 means that 2000-2069,70-100 represents 1970-2000.

2, convert timestamp to date format, date (' y-m-d h:i:s ', $str)

<?php/** * Created by Phpstorm. * user:58 * DATE:2016/9/19 * time:15:56 * * $str = ' 1474274570 '; Echo Date (' y-m-d h:i:s ', $str);

Date function in PHP

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.