当前位置:网站首页>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 .
边栏推荐
- Full resolution of the use of go native plug-ins
- Play with poetry - appreciate the beauty of ancient poetry
- PHP获取本周所有日期或者最近七天所有日期
- Unity one key replacement of objects in the scene
- Skiasharp's WPF self drawn drag ball (case version)
- Unity 一键替换场景中的物体
- 15. User web layer services (III)
- 2022.07.12 summer training personal qualifying (VII)
- Lua对table进行深拷贝
- Laravel $object->updated_at 返回的是Carbon对象,如何返回正常时间格式
猜你喜欢

Alexnet - paper analysis and reproduction

15. User web layer services (III)
![[leetcode] 8. binary search · binary search](/img/35/c4ff66c124754c2a9a7d63b8040e4a.png)
[leetcode] 8. binary search · binary search

Know the optical fiber interface and supporting optical fiber cable of can optical fiber converter in fire alarm networking

Service workers let the website dynamically load webp pictures

使用百度飞桨 EasyDL 完成垃圾分类

Idea replication module

Unity 一键替换场景中的物体

Docker runs MySQL service

15、用户web层服务(三)
随机推荐
Design process sharing of wireless anti loss alarm based on single chip microcomputer
SQL注入 Less26(过滤空格和注释符,使用不带空格的报错注入)
The principle and use of the wrap file of tolua
Full resolution of the use of go native plug-ins
Notes on using objectanimator
DNS series (III): how to avoid DNS spoofing
[real question of written examination]
Play with poetry - appreciate the beauty of ancient poetry
一些知识概念
Know the optical fiber interface and supporting optical fiber cable of can optical fiber converter in fire alarm networking
Hcip day 6 (OSPF related knowledge)
华为发布HarmonyOS 3及全场景新品,智慧体验更进一步
Upgrading of computing power under the coordination of software and hardware, redefining productivity
jar 包内文件的遍历以及文件的拷贝
Specific process of strong cache and negotiation cache
Rest style
Business visualization - make your flowchart'run'(4. Actual business scenario test)
2022.07.12 summer training personal qualifying (VII)
15. User web layer services (III)
Untiy中控制Animation的播放速度