Web Hosting Talk







View Full Version : PHP MSSQL DateTime


mksolutions
03-29-2004, 08:40 PM
I have dates stored in a database with the form of '01/01/2001'. The field is smalldatetime. The output when I return the values ends up being 'Jan 1, 2003 12:00AM' How can I format that value to something that is a little more usefull (Like 'Jan 1, 2003')?

Thanks!

Matthew

luki
03-30-2004, 04:12 AM
In mySQL you can do:

SELECT DATE_FORMAT(date_field_name, "%b %d, %Y") ... FROM ... WHERE ...;

Maybe this also works for MSSQL... or just use mySQL :)

Burhan
03-30-2004, 04:33 AM
How about echo date("M j, Y",strtotime("Jan 1, 2003 12:00 AM"));

mksolutions
03-30-2004, 08:32 AM
Thanks so much for the help! It ended up working like this:

$Date = date("M j, Y",strtotime("$SmallDateTime"));

Thanks again!

Matthew