Page 1 of 1

Basic Date Formatting Question

Posted: Sun Mar 14, 2010 11:06 pm
by dgny06
I know it is a basic question, but let's say that I have a variable called "gameDate" that returns a date from a database. The output is coming back as 2010-02-02 00:00:00, however I would like to remove the "00:00:00" from the string. Since I am not formatting a date, but rather the variable that returns a date, can you please let me know how to do this?

Thanks in advance!!!

Re: Basic Date Formatting Question

Posted: Sun Mar 14, 2010 11:44 pm
by s.dot
http://www.php.net/manual/en/datetime.format.php

Or what I would do is turn it into a timestamp and use the date() function to format it.

Re: Basic Date Formatting Question

Posted: Mon Mar 15, 2010 10:53 am
by pickle
Change your query to use the DATE() function: http://dev.mysql.com/doc/refman/5.1/en/ ... ction_date

Or, failing that, use strtotime:

Code: Select all

$justDate = date('Y-m-d',strtotime($dateTimeFromDB));