当前位置:网站首页>PHP date time application: add or subtract the number of days of a specific date
PHP date time application: add or subtract the number of days of a specific date
2022-07-28 12:15:00 【History teacher-】
The theme of this article is “ How to write a PHP Script to add / Subtract the number of days from a specific date ”.
Let's use PHP How many days before output , How many days later .
1. Look directly at the code
PHP The code is as follows :
1 2 3 4 5 6 7 8 9 |
|
In the above code , We gave a date “2021-09-15”, Then a number of days was specified “50”.
Finally through -、+ The operator finds the date 50 Days ago and 50 Days after .
Of course, there are two important functions that you need to master , Namely strtotime and date:
strtotime() The function parses the date or time description of any English text into Unix Time stamp ( since January 1 1970 00:00:00 GMT Seconds from ).
notes :
m/d/y or d-m-y Format date , If the separator is a slash (/), The American m/d/y Format . If the separator is a horizontal bar (-) Or point (.), Use European d-m-y Format . To avoid potential mistakes , You should use... Whenever possible YYYY-MM-DD Format or use date_create_from_format() function .
date() The function formats the local date and time , And returns the formatted date string .
notes :
PHP 5.1.0: newly added E_STRICT and E_NOTICE The timestamp of the valid range of time zone error is from 1901 year 12 month 13 Japan 20:45:54 GMT Friday To 2038 year 1 month 19 Japan 03:14:07 GMT Tuesday 5.1.0 Previous version , On some systems ( for example Windows) The timestamp is limited from 01-01-1970 To 19-01-2038.
PHP 5.1.1: New standard date / Time format constants , Is used to specify the format Parameters .
边栏推荐
- [diary of supplementary questions] [2022 Niuke summer multi school 2] l-link with level editor I
- Skiasharp's WPF self drawn drag ball (case version)
- Interpretable ml of Li Hongyi's machine learning model
- Lua 中 __index、__newindex、rawget、rawset的理解
- Full resolution of the use of go native plug-ins
- STL concept and its application
- Idea replication module
- 2022.07.12 summer training personal qualifying (VII)
- Latex矩阵简单使用
- Distributed system (III) construction of distributed transaction service
猜你喜欢

Yolov3 complete explanation - from the perspective of data coding

LyScript 获取上一条与下一条指令

Live: never believe that suffering is worth it. Suffering is suffering

Training mode and practice of digital applied talents in Colleges and Universities under the integration of industry and education

Lua middle__ index、__ Understanding of newindex, rawget and rawset

Modify the running container port mapping

程序的存储态与运行态

直接插入排序与希尔排序

ViewPager2+Fragment

Saltstack command injection vulnerability analysis (cve-2020-16846)
随机推荐
Several ways to bind controls --butterknife/viewbinding/databinding
2022.07.12 summer training personal qualifying (VII)
DNS series (III): how to avoid DNS spoofing
Service workers let the website dynamically load webp pictures
QT writing IOT management platform 42 data query export print
Consumer installation and configuration
Character function and string function (Part 1)
[diary of supplementary questions] [2022 Niuke summer school 2] h-take the elevator
Rest style
Some knowledge concepts
laravel表单数据验证
Gecko competition 2.0 is new! Come and show your flexible operation skills!
Detailed explanation of boost official website search engine project
How async await implements concurrency
tolua之wrap文件的原理与使用
2022.07.10 summer training personal qualifying (V)
Article summary of MinGW installation and use
Redis安装
2022.07.07 summer training personal qualifying (II)
Lua makes a deep copy of table