SolutionCottage.com
Posted  29 Oct 2009 - 12:58:13

Category: PHP


Convert a string to date in PHP

Issue:
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.

Solution:

$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 http://www.frivmini.com


Website: http://www.frivmini.com








© SolutionCottage 2008-2011 7/26/2017 1:42:14 AM