Use strtotime().

$result = mysql_query("SELECT datefield FROM mytable");
$row = mysql_fetch_array($result);
echo date('m-d-Y', $datevar);


"David Johansen" <[EMAIL PROTECTED]> wrote:
> I was just wondering if there's any way to work with dates returned from a
> MySQL query in PHP. Right now I do all of different stuff in my MySQL
> but it's really cumbersome, so I would like to be able to do it all with
> PHP. Is there any way to do that? Thanks,
> Dave
> Here's my MySQL query:
> $result = mysql_query("SELECT *, WEEKDAY(time0_name) AS day,
> DATE_FORMAT(time0_name,'%m/%d/%y') AS print_date, DATE_FORMAT(time0_name,
> '%l:%i %p') AS begin_time0, DATE_FORMAT(DATE_ADD(time0_name, INTERVAL 2
> HOUR), '%l:%i %p') AS end_time0, DATE_FORMAT(time1_name, '%l:%i %p') AS
> begin_time1, DATE_FORMAT(DATE_ADD(time1_name, INTERVAL 2 HOUR), '%l:%i
> AS end_time1, DATE_FORMAT(time2_name, '%l:%i %p') AS begin_time2,
> DATE_FORMAT(DATE_ADD(time2_name, INTERVAL 2 HOUR), '%l:%i %p') AS
> DATE_FORMAT(time3_name, '%l:%i %p') AS begin_time3,
> DATE_FORMAT(DATE_ADD(time3_name, INTERVAL 2 HOUR), '%l:%i %p') AS
> DATE_FORMAT(time4_name, '%l:%i %p') AS begin_time4,
> DATE_FORMAT(DATE_ADD(time4_name, INTERVAL 2 HOUR), '%l:%i %p') AS
> DATE_FORMAT(time5_name, '%l:%i %p') AS begin_time5,
> DATE_FORMAT(DATE_ADD(time5_name, INTERVAL 2 HOUR), '%l:%i %p') AS
> FROM pickup_times",$dbh);
> I could do it a lot easier if in PHP I think, so I was just wondering if
> anyone could point me to a thing that talked about converting MySQL
> to PHP date stuff.

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to