Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert php date time to string

Shulou Source: shulou.com Published: 2022-06-03 20:23:14 11月12日 Update

This article mainly shows you "php date and time how to convert into a string", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn how to convert php date and time into a string "this article.

Php date-time conversion methods: 1, create a PHP sample file; 2, new a DateTime;3, through "$datetime- > format ('jS, F Y')" date-time conversion into a string can be.

Operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer

How is the php date time converted to a string?

PHP uses the DateTime class to convert time, date to string

PHP's handling of time and date is not very standard, it is simple, just do not know whether the input string can be correctly converted to the desired DateTime type.

Object-oriented PHP should use DateTime class to convert string to dateTime.

From string to time type

DateTime::createFromFormat ('m/d/Y totalPrice=0.0 totalPrice=0.0') 03Universe 01bot 2008 02purl)

From DateTime to string

$datetime = new DateTime ('2008-08-03 14 echo 52 datetime- 10'); $datetime- > format ('jS, F Y'). "/ n"

Get the current time

Getdate ()

Although this operation is a bit troublesome, but each part is their own precise control of the format, feel at ease a little bit.

All of the above are for PHP 5.3 or above.

The old version still needs to use this.

Echo date ('m/d/Y Hlypher iTunes journal strtotime (' 10 take 20 hands 2009 15 21'))

Note: what is read from the database with an array is a character type

The above is all the contents of the article "how to convert php date and time into a string". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Character string time date content article version type learning help character type precision then object that is data database array file method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Apple OPPO Reno Microsoft