changing mssql date

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

changing mssql date

Post by valen53 »

normally date format in mssql are datetime...
when select the date , result will be 03/25/2003 1200:0:0 something like that..

any method can changing that only display date?
no matter i use below which method , the result incorrect ..

$pdate = date("M/d/Y", mktime($row[APPLY_DATE])) ;

$pdate1 = date("M, d Y", $row[DATE_TO]) ;

any one can help me ...
thank u
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you tried to format the date in the database? MySQL has a function called DATE_FORMAT() does MS SQL have something similar?

The reason the code you have is not working is because you are using mktime() incorrectly:
http://www.php.net/manual/en/function.mktime.php

If you can't format the date in the database (which is preferable) you need to split up the date and time into it's constituent parts - seconds, minutes, hours, day, month, year - before you can use it in mktime():
http://www.php.net/manual/en/function.explode.php

Mac
Post Reply