Usage Analysis of the strtotime function in PHP, phpstrtotime

Source: Internet
Author: User

Usage Analysis of the strtotime function in PHP, phpstrtotime

This article describes the use of the time addition and subtraction function strtotime in PHP. We will share this with you for your reference. The details are as follows:

Time addition and subtraction

<? Php // obtain the year of local extraction + 1 $ date = date ("Y-m-d", mktime (, 0, date ("m "), date ("d"), date ("Y") + 1);?>

What should I do if I want to get the time in the database? A good function strtotime is found in the PHP document. You can add or subtract the time:

int strtotime ( string time [, int now] )

Return type int

Functions can be used for time conversion and addition/subtraction.

<? Php // date () format time returns the String type. // Add one year $ date_year = date ('Y-m-d', strtotime ("$ date + 1 year"); echo $ date_year; // Add one day $ date_tomorrow = date ('Y-m-d', strtotime ("+ 1 day"); echo $ date_tomorrow; // Add a week $ date_week = date ('Y-m-d', strtotime ("$ date + 1 week"); echo $ date_week;?>

PS: here we recommend several time and date related tools for your reference:

Online date/day calculator:
Http://tools.jb51.net/jisuanqi/date_jisuanqi

Online date calculator/days calculator:
Http://tools.jb51.net/jisuanqi/datecalc

Online date-days difference calculator:
Http://tools.jb51.net/jisuanqi/onlinedatejsq

Unix timestamp Conversion Tool:
Http://tools.jb51.net/code/unixtime

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.