当前位置:网站首页>PHP date calculation operation processing, the current date plus one day and the specified date minus one day
PHP date calculation operation processing, the current date plus one day and the specified date minus one day
2022-07-28 12:15:00 【History teacher-】
1. Add one day to the current time ?
<?php
echo " today :",date('Y-m-d H:i:s'),"<br>";
echo " Tomorrow, :",date('Y-m-d H:i:s',strtotime('+1 day'));
?>
The previous line outputs the current time , The next line outputs tomorrow's time
Similarly, add one year , An hour , A minute , January ...
echo " Tomorrow, :",date('Y-m-d H:i:s',strtotime('+1 day'));
echo " Tomorrow, :",date('Y-m-d H:i:s',strtotime('+1 hour'));
echo " Tomorrow, :",date('Y-m-d H:i:s',strtotime('+1 minute'));
echo " Tomorrow, :",date('Y-m-d H:i:s',strtotime('+1 mouth'));
here +1 day Parameters can be modified 1 For any number you want day It can also be changed to year( year ),month( month ),hour( Hours )minute( branch ),second( second ) Such as :
date('Y-m-d H:i:s',strtotime("+1 day +1 hour +1 minute");
You can combine freely , To achieve the purpose of arbitrary output time
notes : This method is only applicable to 1970 Applicable after , That is, the applicable scope of timestamp .
2. Add one day to the specified time ? An hour ?......
echo date("Y-m-d",strtotime("+1 month",strtotime("2012-02-04")));
The result is :2011-03-04
echo date("Y-m-d",strtotime("+1 week",strtotime("2011-02-04")));
The result is :2011-02-11
echo date("Y-m-d",strtotime("+1 day",strtotime("2011-02-04")));
The result is :2011-02-05
The same is true for others .
notes : This method is only applicable to 1970 Applicable after , That is, the applicable scope of timestamp .
Then subtract one or several days ?
Same method , Just change the plus sign into a minus sign .
<?php
echo " today :",date('Y-m-d H:i:s'),"<br>";
echo " yesterday :",date('Y-m-d H:i:s',strtotime('-1 day'));
?>边栏推荐
- Lua 中 __index、__newindex、rawget、rawset的理解
- boost官网搜索引擎项目详解
- consul安装与配置
- Hcip rip comprehensive experiment
- ES6 knowledge points supplement
- Zhou Hongyi talks about Internet thinking: users, not customers
- Saltstack command injection vulnerability analysis (cve-2020-16846)
- Unitywebrequest is used in unity to load network and local pictures
- Google Earth engine (GEE) -- problems in the use of coordinate projection and reduceresolution functions in image downscaling
- REST风格
猜你喜欢

A new mode of one-stop fixed asset management
![[leetcode] 8. binary search · binary search](/img/35/c4ff66c124754c2a9a7d63b8040e4a.png)
[leetcode] 8. binary search · binary search

Several ways to bind controls --butterknife/viewbinding/databinding

Saltstack command injection vulnerability analysis (cve-2020-16846)

Ruiji takeout - day01

Lua对table进行深拷贝

Rest style

Gecko competition 2.0 is new! Come and show your flexible operation skills!

Redis安装

Docker runs MySQL service
随机推荐
IRBuilder
云原生机器学习落地难?灵雀云助力企业快速应用 MLOps
laravel表单数据验证
Know the optical fiber interface and supporting optical fiber cable of can optical fiber converter in fire alarm networking
程序的存储态与运行态
Full resolution of the use of go native plug-ins
Force buckle 7_ 1672. Total assets of the richest customers
Detailed deployment and configuration of CEPH cluster (II)
P5472 [noi2019] douzhudi (expectation, Mathematics)
Full analysis of seven classical regression analysis methods
WebView详解
2022.07.12 summer training personal qualifying (VII)
Interpretation of the paper: attention mechanism in medical images
Reasons and solutions for moving the first column to the last column in El table
华为发布HarmonyOS 3及全场景新品,智慧体验更进一步
Hcip (condition matching and OSPF packet related knowledge)
Unity遇坑记之 ab包卸载失败
STL の 概念及其应用
ES6 knowledge points supplement
Modify the running container port mapping