Page 1 of 1

date conversion

Posted: Wed Apr 02, 2003 9:28 pm
by valen53
i use sql2000, so the date format i query are apr, 1 2003, 12:00
but i want split it to 04/01/2003 ...
but i can't change the date format from apr to 04..
below is my code.. anyone can help me ??
thank u

list ($mon,$day,$year, $time) = split (' ', $Itemrow[StartDate]) ;
$repairDate = date('m/d/Y', mktime(0,0,0, "$mon,$day,$year"));

Posted: Wed Apr 02, 2003 9:40 pm
by Malder
try explode instead of split

Posted: Wed Apr 02, 2003 9:58 pm
by valen53
Malder wrote:try explode instead of split
actually not split problem , i just split the date. but apr is string ..
when use mktime (0,0,0 int,int,int ) so i can't convert it string to int..

list ($mon,$day,$year, $time) = explode(' ', $Itemrow[StartDate]) ;
$repairDate = date('m/d/Y', mktime(0,0,0, $mon,$day,$year));

Posted: Wed Apr 02, 2003 11:28 pm
by Tubbietoeter
oracle has a date conversion function, don't know whether you sql has something similar:

to_char(datefield,'DD-MM-YYYY');


maybe check on that so you don't have to parse the date

Posted: Thu Apr 03, 2003 1:35 am
by twigletmac
If you can't adjust the date in the database (which would be the best solution) then you should look into strtotime():
http://www.php.net/manual/en/function.strtotime.php

Mac