Posted  29 Oct 2009 - 12:58:13

Category: PHP

Convert a string to date in PHP

You have a string, from a database for example and you want to convert this to a date in PHP to be able to format it or what have you. In my example I wanted to take a string date, convert it to a date object and finally display just the date, excluding the time.


$only_date = date("Y-m-d",strtotime($row['published']));

1 comment:

11/28/2016 6:14:08 AM  Friv  wrote:

Hello. I new learned php, I have encountered this problem, and I have the answer here, thanks a lot


© SolutionCottage 2008-2011 9/24/2017 1:12:30 PM