search
HomeBackend DevelopmentPHP ProblemHow to get the current number in php

In PHP, you can get the current date through the "PHP Date()" function. The syntax of this function is "date(format, timestamp)", where when the "format" parameter is "d", It means getting the day of the month.

How to get the current number in php

Recommended: "PHP Video Tutorial"

To get the current time, you need to use the PHP Date() function.

PHP Date() Format the timestamp into a more readable date and time.

Syntax:

date(format,timestamp)

The parameter format is the display format, and the parameter timestamp is the timestamp, which is optional. The default is time(), that is, if no timestamp is given, the local current is used. time.

format format parameters are briefly introduced here:

Some characters commonly used in dates:

Y - Complete representation of the year (four digits: 2019)

y - represents the year (two digits: 19)

F - represents the month (full text format: January or March)

M - represents the month (3 letters: Jun )

m - indicates the month, with leading 0 (number: 04)

n - indicates the month, without leading 0 (number: 4)

d - indicates the middle of the month The day of the month, with leading 0 (01-31)

j - represents the day of the month, without leading 0 (1-31)

D - represents the day of the week (3 Letter: Wed)

l - represents the day of the week (full English: Wednesday)

w - represents the day of the week (number, 0 represents Sunday)

W - Indicates the number of weeks in the year

z - Indicates the number of days in the year (0-366)

Example:

<?php
    echo "<p>今天是:" . date("Y/m/d") . "</p>";
    echo "<p>今天是:" . date("Y.m.d") . "</p>";
    echo "<p>今天是:" . date("Y-m-d") . "</p>";
    echo "<p>今天是:" . date("l") . "</p>";
?>

Run results:

PHP gets the current time, year, month, date and number of days PHP notes No. 2

If you want the year, month and day in Chinese, you can write like this:

echo "The current time is:" . date("Y year m month d day");

Run result:

Today is: April 24, 2019

The above is the detailed content of How to get the current number in php. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools