How to convert PHP string into time: first create a PHP sample file; then define a variable "$temp_date"; finally pass "date('Y-m-d',strtotime($temp_date));" Just convert the string variable into time.

#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
php string formatting into time
In normal times we often need to format the time of a string before using it
Php can use the following method:
$temp_date = '2011-01-09 19:25:43'; date('Y-m-d',strtotime($temp_date)); //这个的输出是 2011-01-09
The function of strtotime is-- Parse the date and time description of any English text into a UNIX timestamp
The following is the official description:
int strtotime ( string time [, int now])
This function is expected to accept a string containing an English date format and try to parse it into a UNIX timestamp. If the format of time is absolute time, the now parameter has no effect.
If the format of time is a relative time, the relative time is provided by now, or the current time is used if the now parameter is not provided. Returns -1 on failure.
The programs must be relatively robust, then we can judge whether they can be converted.
It should also be noted that this has a time interval: Friday, December 13, 1901 at 20:45 :54 Until Tuesday, January 19, 2038 03:14:07
[Recommended learning: "PHP Video Tutorial"]
The above is the detailed content of How to convert php string to time. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment






