PHP method to obtain the specific time of each time period
This article mainly introduces the method of obtaining the specific time of each time period through PHP programming, and analyzes the related operating skills of date and time operations based on the date and strtotime functions in the form of examples. Friends in need can refer to the following
The details are as follows:
<?php echo "今天:".date("Y-m-d")."<br>"; echo "昨天:".date("Y-m-d",strtotime("-1 day")), "<br>"; echo "明天:".date("Y-m-d",strtotime("+1 day")). "<br>"; echo "一周后:".date("Y-m-d",strtotime("+1 week")). "<br>"; echo "一周零两天四小时两秒后:".date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")). "<br>"; echo "下个星期四:".date("Y-m-d",strtotime("next Thursday")). "<br>"; echo "上个周一:".date("Y-m-d",strtotime("last Monday"))."<br>"; echo "一个月前:".date("Y-m-d",strtotime("last month"))."<br>"; echo "一个月后:".date("Y-m-d",strtotime("+1 month"))."<br>"; echo "十年后:".date("Y-m-d",strtotime("+10 year"))."<br>"; /* strtotime()函数的作用是将日期时间描述解析为 Unix 时间戳 int strtotime ( string time [, int now] ) */ ?>
The running results are as follows:
今天:2017-05-26 昨天:2017-05-25 明天:2017-05-27 一周后:2017-06-02 一周零两天四小时两秒后:2017-06-04 6:06:39 下个星期四:2017-06-01 上个周一:2017-05-22 一个月前:2017-04-26 一个月后:2017-06-26 十年后:2027-05-26
Related recommendations:
How to implement programming in PHP to calculate whether two time periods have intersection
PHP MySQL Detailed explanation of data statistics optimization steps within a fixed time period
PHP combines with Redis to restrict users or IPs Number of visits during time period
The above is the detailed content of PHP method to obtain the specific time of each time period. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

Validator can be created by adding the following two lines in the controller.
