Home Backend Development PHP Tutorial disk error press any key to re Arrangement of parameters related to date function in PHP

disk error press any key to re Arrangement of parameters related to date function in PHP

Jul 29, 2016 am 08:46 AM

Add
date_default_timezone_set(PRC) to the front page of the page; /*Adjust the time to Beijing time, php5 defaults to Greenwich Mean Time*/
date ()
a: "am" or "pm"
A: "AM" or "PM"
d: Day, two digits, zero if missing; from "01" to "31"
D: Day of the week, 3 English letters, such as: "Fri"
F : month, full English name, such as: "January"
h: hour in 12-hour format, from "01" to "12"
H: hour in 24-hour format, from "00" to "23"
g: 12 Hours in hourly format, do not add zeros; from "1" to "12"
G: Hours in 24-hour format, do not add zeros; from "0" to "23"
j: Days, any deficiency will not be zeroed; from "1" to "31"
l: day of the week, full English name, such as: "Friday"
m: month, two digits, from "01" to "12"
n: month, two digits, no padding Zero; from "1" to "12"
M: month, 3 English letters; such as: "Jan"
s: seconds; from "00" to "59"
S: add an English ordinal at the end of the word, two English letters Letters, such as: "21th"
t: Specify the number of days in the month, from "28" to "31"
U: Total seconds
w: Numeric day of the week, from "0 (Sunday)" to "6 (Saturday) )"
Y: year, four digits
y: year, two digits
z: day of the year; from "1" to "366"
============ ================================================== ====
1, year-month-day
indicates the year with uppercase Y and lowercase y;
indicates the month with uppercase F, uppercase M, lowercase m and lowercase n (two ways to represent characters and numbers respectively) );
You can use lowercase d and lowercase j to represent the day, and uppercase S represents the suffix of the date.
echo date('Y-m-j');
2007-02-6
echo date('y-n-j');
07-2-6
Uppercase Y represents the four-digit year, while lowercase y represents the two digits of the year digits;
lowercase m represents the number of the month (with leading), while lowercase n represents the number of the month without the leading.
echo date('Y-M-j');
2007-Feb-6
echo date('Y-m-d');
2007-02-06
Capital M represents the 3 abbreviation characters of the month, while lowercase m represents The number of the month (with leading 0);
There is no uppercase J, only lowercase j represents the date of the month, without the leading o; if the month needs to be preceded, use lowercase d.
echo date('Y-M-j');
2007-Feb-6
echo date('Y-F-jS');
2007-February-6th
Capital M represents the 3 abbreviation characters of the month, while capital F represents the month written in full English. (No lowercase f)
Capital S represents the suffix of the date, such as "st", "nd", "rd" and "th", depending on the date number.
2, hours: minutes: seconds
By default, the time displayed by PHP interpretation is "Greenwich Mean Time", which is 8 hours different from our local time.
echo date('g:i:s a');
5:56:57 am
echo date('h:i:s A');
05:56:57 AM
lowercase g represents the 12-hour clock, There is no leading 0, and the lowercase h represents the 12-hour clock with leading 0.
When using the 12-hour clock, you need to indicate morning and afternoon. Lowercase a represents lowercase "am" and "pm", and uppercase A represents uppercase "AM" and "PM".
echo date('G:i:s');
14:02:26
Capital G represents the hour in 24-hour format, but without leading; use capital H to represent the hour in 24-hour format with leading
Summary:
The letter g represents the hour without a leading, the letter h represents the hour with a leading;
The lowercase g and h represent the 12-hour format, and the uppercase G and H represent the 24-hour format.
3, leap year, week, day
echo date('L');
Whether this year is a leap year: 0
echo date('l');
Today is: Tuesday
echo date('D');
Today is: Tue
Capital L means to determine whether this year is a leap year, Boolean value, returns 1 if true, otherwise 0;
Lowercase l means the full English version of the day of the week (Tuesday);
Use capital D to represent the 3 characters of the day of the week Abbreviation (Tue).
echo date('w');
Today's week: 2
echo date('W');
This week is the 06th week of the year
Lowercase w represents the day of the week, in numerical form
Capital W represents the year The number of the week in
echo date('t');
This month has 28 days
echo date('z');
Today is the 36th day of this year
Lowercase t means how many days in the current month
Lowercase z means today It is the day of the year
4, others
echo date('T');
UTC
Capital T indicates the time zone setting of the server
echo date('I');
0
Capital I indicates whether the current time is Daylight saving time, returns 1 if true, otherwise 0
echo date('U');
1170769424
Uppercase U represents the total number of seconds from January 1, 1970 to the present, which is the UNIX timestamp of the Unix time epoch.
echo date('c');
2007-02-06T14:24:43+00:00
lowercase c represents the ISO8601 date, the date format is YYYY-MM-DD, use the letter T to separate the date and time, the time format For HH:MM:SS, the time zone is expressed as an offset from Greenwich Mean Time (GMT).
echo date('r');
Tue, 06 Feb 2007 14:25:52 +0000
lowercase r represents the RFC822 date.
5. Format time
echo $row["t_time"]; will output 2008-2-29 12:08:00
echo date("Y-m-d",strtotime($row["t_time"])); will output 2008-2-29
Note, since the time obtained by $row["t_time"] is already a string, you need to use strtotime (string to timestamp) to convert it, otherwise the error of 1970-01-01 will be output.

The above has introduced the arrangement of parameters related to the date function in PHP, including the content of disk error press any key to re. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

See all articles