PHP gets today, yesterday, tomorrow's date
Go directly to the code and explain
<?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] ) PHP星期几获取代码: date("l"); //data就可以获取英文的星期比如Sunday date("w"); //这个可以获取数字星期比如123,注意0是星期日 获取中文星期可以这样 $weekarray=array("日","一","二","三","四","五","六"); echo "星期".$weekarray[date("w")]; 获取指定日期是: $weekarray=array("日","一","二","三","四","五","六"); echo "星期".$weekarray[date("w","2011-11-11")]; 因为date函数非常强大,他完全可以胜任一切这样的工作我附个手册里的表吧 a - "am" 或是 "pm" A - "AM" 或是 "PM" d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31" D - 星期几,三个英文字母; 如: "Fri" F - 月份,英文全名; 如: "January" h - 12 小时制的小时; 如: "01" 至 "12" H - 24 小时制的小时; 如: "00" 至 "23" g - 12 小时制的小时,不足二位不补零; 如: "1" 至 12" G - 24 小时制的小时,不足二位不补零; 如: "0" 至 "23" i - 分钟; 如: "00" 至 "59" j - 几日,二位数字,若不足二位不补零; 如: "1" 至 "31" l - 星期几,英文全名; 如: "Friday" m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12" n - 月份,二位数字,若不足二位则不补零; 如: "1" 至 "12" M - 月份,三个英文字母; 如: "Jan" s - 秒; 如: "00" 至 "59" S - 字尾加英文序数,二个英文字母; 如: "th","nd" t - 指定月份的天数; 如: "28" 至 "31" U - 总秒数 w - 数字型的星期几,如: "0" (星期日) 至 "6" (星期六) Y - 年,四位数字; 如: "1999" y - 年,二位数字; 如: "99" z - 一年中的第几天; 如: "0" 至 "365"
The above introduces PHP to get today, yesterday, and tomorrow's date, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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



If you're looking for a way to automatically create and name files and folders based on system timestamps, you've come to the right place. There is a super simple way to accomplish this task. The created folders or files can then be used for various purposes such as storing file backups, sorting files based on date, etc. In this article, we will explain in some very simple steps how to automatically create files and folders in Windows 11/10 and name them according to the system’s timestamp. The method used is a batch script, which is very simple. Hope you enjoyed reading this article. Section 1: How to automatically create and name a folder based on the current timestamp of the system Step 1: First, navigate to the parent folder where you want to create the folder,

When developing using PHP programs, you often encounter some warning or error messages. Among them, one error message that may appear is: PHPWarning:date()expectsparameter2tobelong,stringgiven. The error message means: the second parameter of the function date() is expected to be a long integer (long), but what is actually passed to it is a string (string). So, we

In today's era of rapid technological development, programming languages are springing up like mushrooms after a rain. One of the languages that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

"Go Language Development Essentials: 5 Popular Framework Recommendations" As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast

1. Introduction The Date class in the java.util package represents a specific time, accurate to milliseconds. If we want to use our Date class, then we must introduce our Date class. Writing the year directly into the Date class will not produce the correct result. Because Date in Java is calculated from 1900, so as long as you fill in the first parameter with the number of years since 1900, you will get the year you want. The month needs to be subtracted by 1, and the day can be inserted directly. This method is rarely used, and the second method is commonly used. This method is to convert a string that conforms to a specific format, such as yyyy-MM-dd, into Date type data. First, define an object of Date type Date

How to get millisecond representation of date using getTime() method of Date class In Java, Date class is a class used to represent date and time. It provides many useful methods to manipulate and obtain information about date objects. Among them, the getTime() method is an important method in the Date class, which can return the millisecond representation of the date object. Next, we will detail how to use this method to obtain the millisecond representation of a date, and provide corresponding code examples. Using the Date class

There are many excellent calendar libraries and date libraries in Python for us to use. These libraries can help us handle date and calendar related operations. Next, I will introduce you to several common choices and provide corresponding code examples. Datetime library: Datetime is Python's built-in date and time processing module. It provides many date and time related classes and methods, which can be used to process dates, times, time differences and other operations. Sample code: importdatetime#Get the current date

With the development of the Internet and the advancement of information technology, the era of big data has arrived, and fields such as data analysis and machine learning have also been widely used. In these fields, task scheduling is an inevitable problem. How to achieve efficient task scheduling is crucial to improving efficiency. In this article, we will introduce how to use Golang's web framework Echo framework to implement distributed task scheduling. 1. Introduction to the Echo framework Echo is a high-performance, scalable, lightweight GoWeb framework. It is based on HTTP
