PHP implementation time plus minus function strtotime usage

Source: Internet
Author: User
This article mainly introduces the Strtotime usage of time plus and minus function in PHP, and analyzes the operation skill of date plus and minus operation by combining Strtotime with date function, which can be referenced by friends.

Time plus minus

<?php//gets the local fetch year +1$date=date ("Y-m-d", Mktime (0,0,0,date ("M"), Date ("D"), Date ("Y") +1)); >

What should you do if you want to get the time in the database? A good function strtotime is found in the PHP documentation, and the time can be added and reduced:

int strtotime ( string time [, int now] )

return type int

Functions can be used for time conversion and subtraction.

<?php//date () Format time returns a string type. Plus one year $date_year = date (' y-m-d ', Strtotime ("$date + 1 Year")), Echo $date _year;//plus Day $date_tomorrow = date (' y-m-d ', Strtotime ("2009-05-26 + 1 Day"), Echo $date _tomorrow;//plus one week $date_week = Date (' y-m-d ', Strtotime ("$date + 1 Week"); echo $ Date_week;? >

The above is the whole content of this article, I hope that everyone's study has helped.


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.