Home Backend Development PHP Tutorial How to use date and time functions in PHP_PHP Tutorial

How to use date and time functions in PHP_PHP Tutorial

Jul 20, 2016 am 10:59 AM
date php use function parameter and how date time yes Format usage

​ (1)date
Usage:
date(format,[time]);
If there is no time parameter, the current time is used.
The format is a string in which the following characters have special meaning:
U is replaced by the number of seconds since a starting time (like January 1, 1970)
Replace Y with the 4-digit year number.
Replace y with the 2-digit year number.
Replace F with the full English name of the month.
M is replaced with the English abbreviation of the month.
m is replaced by the number of months.
Replace z with the number of days since January 1st of the current year.
d is replaced by the number of days.
l Replace with the full English name of the day of the week.
Replace D with the English abbreviation of the day of the week.
w is replaced by the day of the week (number).
H is replaced by the number of hours (24-hour format).
h is replaced by the number of hours (12-hour format).
Replace i with minutes.
Replace s with seconds.
Replace A with "AM" or "PM".
Replace a with "am" or "pm".
Replace S with an ordinal suffix, such as: "st", "nd", "rd", "th".
The function returns the replaced format string.
(2)getdate(time)
Returns a hash table, each subscript is:
"seconds" -- number of seconds
"minutes" -- Score
"hours" -- number of hours
"mday" -- day number
"mon" -- number of months
"year" -- year number
"yday" -- the number of days since January 1
"weekday" -- day of the week, full English name
"month" -- month, full English name
(3)gmdate
Similar to date, but first convert the time to Greenwich Mean Time.
(4)mktime
Usage:
mktime(hours, minutes, seconds, months, days, years);
Returns a time value that can be used in other functions.
(5)time
Usage:
time();
Returns the number of seconds since midnight on January 1, 1970.
(6)microtime
Usage:
microtime();
Returns a string, divided into two parts with spaces, the latter part is equivalent to time()
The return value of , the first part is the number of microseconds.
(7)checkdate
Usage:
checkdate(month, day, year);
Returns logical true or logical false.
If:
[1] The year is between 1900 and 32767 (including 1900 and 32767);
[2]The month is between 1 and 12;
[3] The day is within the allowed number of days in the month (leap years are taken into account);
then returns logical true.
(8)set_time_limit
Usage:
set_time_limit(seconds);
It stipulates that the program must run to completion within the specified number of seconds from the time this sentence is run,
If the timeout occurs, the program will exit with an error.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445587.htmlTechArticle(1)date usage: date(format,[time]); If there is no time parameter, the current time is used . The format is a string in which the following characters have special meaning: U is replaced by starting from a starting time (well...
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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks 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)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles