PHP Gets the current time and calculates the time of day, week, month, year

Source: Internet
Author: User

Get current time:

$now Date (' y-m-d h:i:s ',Time ());  

Get the current time in one minute:

Date ("Y-m-d h:i:s",strtotime("+1minutes",strtotime($now)))

Get the time after one hour of the current time:

Date ("Y-m-d h:i:s",strtotime("+1hours",strtotime($now)))

Get the time of day after the current time:

Date ("Y-m-d h:i:s",strtotime("+1date",strtotime($now)))

Get the time of the week after the current time:

First Kind Date ("Y-m-d h:i:s",strtotime("+7days",strtotime($now)))
Second date("Y-m-d h:i:s",strtotime("+1weeks",strtotime($now)))

Gets the time after January of the current time:

Date ("Y-m-d h:i:s",strtotime("+1months",strtotime($now)))

Get the time after one year of the current time:

Date ("Y-m-d h:i:s",strtotime("+1years",strtotime($now)))

PHP Gets the current time and calculates the time of day, week, month, year

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.