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 to convert php date time to string

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

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!

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