Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How php converts the value obtained by time () into a date string

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly describes how php time() to obtain the value of the date string form of related knowledge, detailed and easy to understand, simple and fast operation, with a certain reference value, I believe we read this article how php time() to obtain the value of the date string form of the article will be harvested, let's take a look at it.

In php, you can convert the value returned by time() to date string form using the date() function, syntax "date("Y-m-d H:i:s",time())". Time() returns a timestamp representing the current time, while date() formats the timestamp and returns a formatted date string.

Operating environment of this tutorial: Windows 7 system, PHP7.1 version, DELL G3 computer

php converts the value obtained by time() to string form

In php, you can use the date() function to convert the value returned by time() to string form.

Description:

The time() function returns the number of seconds of the current time since the Unix epoch (January 1 1970 00:00:00 GMT).

The date() function formats the local date and time and returns a formatted date string. The syntax is as follows:

date(format,timestamp); Parameter Description format

Required. Specifies the format of the output date string. The following characters can be used:

d -Day of the month (from 01 to 31)

D -Text representation of day of week (represented by three letters)

j -Day of the month without leading zeros (1 to 31)

l (lowercase form of 'L')-full text representation of day of week

N -ISO-8601 numerical representation of the day of the week (1 for Monday, 7 for Sunday)

S -English ordinal suffix for the day of the month (2 characters: st, nd, rd, or th. Used with j)

w -Numeric representation of day of week (0 for Sunday, 6 for Saturday)

z -Day of the year (from 0 to 365)

W -Number of weeks of the year in ISO-8601 numeric format (weeks start on Monday)

F -Full text representation of month (January to December)

m -Numeric representation of the month (from 01 to 12)

M -Short text representation of the month (represented by three letters)

n -Numeric representation of the month without leading zeros (1 to 12)

t -Number of days in a given month

L -whether it is a leap year (1 if leap year, 0 otherwise)

o -Year number under ISO-8601

Y -four-digit representation of year

y -Two-digit representation of the year

a -Lowercase: am or pm

A -capital form: AM or PM

Swatch Internet Time (000 to 999)

g - 12 hour clock without leading zeros (1 to 12)

G - 24 hour clock without leading zeros (0 to 23)

h - 12 hour clock with leading zeros (01 to 12)

H - 24 hour clock with leading zeros (00 to 23)

i-min, with leading zeros (00 to 59)

s -seconds with leading zeros (00 to 59)

u -microseconds (new in PHP 5.2.2)

e -Time zone identifier (e.g. UTC, GMT, Atlantic/Azores)

I (capital form of i)-whether the date is in daylight saving time (1 if daylight saving time, 0 otherwise)

O -difference in Greenwich Mean Time (GMT) in hours (example: +0100)

P -difference in GMT in hours:minutes (new in PHP 5.1.3)

T -Abbreviation for time zone (examples: EST, MDT)

Z -Time zone offset in seconds. Negative offset for time zones west of UTC (-43200 to 50400)

c -Date of ISO-8601 standard (e.g. 2013-05-05T16:34:42+00:00)

r -Date in RFC 2822 format (for example Fri, 12 Apr 2013 12:01:05 +0200)

U -Number of seconds elapsed since Unix epoch (January 1 1970 00:00:00 GMT)

The following predefined constants (available from PHP 5.1.0) are also available:

DATE_ATOM - Atom (e.g. 2013-04-12T15:52:01+00:00)

DATE_COOKIE - HTTP Cookies (e.g. Friday, 12-Apr-13 15:52:01 UTC)

DATE_ISO8601 - ISO-8601 (e.g. 2013-04-12T15:52:01+0000)

DATE_RFC822 - RFC 822 (e.g. Fri, 12 Apr 13 15:52:01 +0000)

DATE_RFC850 - RFC 850 (e.g. Friday, 12-Apr-13 15:52:01 UTC)

DATE_RFC1036 - RFC 1036 (e.g. Fri, 12 Apr 13 15:52:01 +0000)

DATE_RFC1123 - RFC 1123 (e.g. Fri, 12 Apr 2013 15:52:01 +0000)

DATE_RFC2822 - RFC 2822(Fri, 12 Apr 2013 15:52:01 +0000)

DATE_RFC3339 -Same as DATE_ATOM (since PHP 5.1.3)

DATE_RSS - RSS(Fri, 12 Aug 2013 15:52:01 +0000)

DATE_W3C -World Wide Web Consortium (e.g. 2013-04-12T15:52:01+00:00)

Timestamp is optional. Unix timestamp specifying an integer. The default is the current local time (time()).

About "php how to get the value of time() into date string form" The content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of "how php converts the value obtained by time() into date string form" knowledge. If you still want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report