Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with formatting date

Status
Not open for further replies.

ericb1

Programmer
Oct 22, 2004
175
US
I'm not a php programmer, but I inherited some code I'm trying to alter. Basically, everything works ok, (php 5, MSSQL2000), but when it pulls a date out of my SQL db, it's re-formatting the date.

The date is stored in mm/dd/yyyy format, but php is somewhere changing that to: "Aug 29 2000 12:00AM"

Where can I change this formatting? The query is pulling all records and just looping through them, so I don't think I can even apply a "date()" type after-the-fact formatting.

Any help is appreciated, thanks!

My code looks like this:

$qr = mssql_query("SELECT * from ".$table.($condition=="" ? "" : " WHERE ClaimantName = '".$condition."' ORDER BY ClaimantName"));
$r_string = 'n='.mssql_num_rows($qr);
$i = 0;
while ($row = mssql_fetch_assoc ($qr)) {
while (list ($key, $val) = each ($row)) {
$r_string .= '&' . $key . $i . '=' . $val ;
}
$i++;
}
 
To my experience, PHP doesn't do much in the way of automagic data formatting, but Microsoft products do. Typically, when a Microsoft product connects to a Microsoft product, there are lots of settings which get set automatically. Those settings are probably not getting set in your PHP script.

See the first user-supplied note on the PHP online manual page for mssql_connect()


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top