PHP

Convert String Date to Date Format in PHP1 min read

In this post you will learn How to Convert a String into Date Format in PHP.

During development of a PHP calendar, I needed to convert a string to a PHP date, suppose the following string:




I wanted to convert this date into a format understandable by PHP: 2015-01-29.

The following code shows in two steps the use of the strtotime() and getDate() function to convert a string date into a PHP date structure:

The structure of the $ date variable will be displayed like this:

it works and even if it is not the best structure that can be obtained, it is possible at least to get the basic information on the day, the month, and the current year.

Leave a Comment