当前位置:网站首页>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 .
边栏推荐
- Hcip (configuration of GRE and mGRE and OSPF related knowledge)
- String function (Part 2)
- 简单选择排序与堆排序
- OSCache cache monitoring Refresh Tool
- Specific process of strong cache and negotiation cache
- 【Try to Hack】udf提权
- Full analysis of seven classical regression analysis methods
- Lua middle__ index、__ Understanding of newindex, rawget and rawset
- Unity中使用UnityWebRequest进行网络和本地图片加载
- Several ways to bind controls --butterknife/viewbinding/databinding
猜你喜欢

Style conversion model style_ Transformer project instance pytorch implementation

Unity one key replacement of objects in the scene

STL concept and its application

laravel表单数据验证
![[leetcode] 6. invert binary tree](/img/1b/fdc5f8904bca319ffc97411213afe8.jpg)
[leetcode] 6. invert binary tree

A new mode of one-stop fixed asset management

Consumer installation and configuration

Docker runs MySQL service

Lua 中 __index、__newindex、rawget、rawset的理解

Lua middle__ index、__ Understanding of newindex, rawget and rawset
随机推荐
Rest style
Final modifier attribute
Alexnet - paper analysis and reproduction
本地化、低时延、绿色低碳:阿里云正式启用福州数据中心
ES6 knowledge points supplement
Zhou Hongyi talks about Internet thinking: users, not customers
Laravel之缓存
php⽉份加减最简单的处理⽅法
Notes on using objectanimator
Test platform (V) knowledge points supplement
[diary of supplementary questions] [2022 Hangdian summer school 2] k-dos card
使用百度飞桨 EasyDL 完成垃圾分类
瑞吉外卖——Day01
Unity encountered a pitfall and the AB package failed to unload
SQL注入 Less24(二次注入)
OSCache cache monitoring Refresh Tool
安徽京准:北斗卫星同步时钟|北斗同步时钟|NTP网络时钟服务器
Stored state and running state of program
laravel表单数据验证
Lua makes a deep copy of table