Re: [PhP - dB] About Formatting a Date Result
- From: "almostbob" <anonymous1@xxxxxxxxxxxxx>
- Date: Sun, 25 Jan 2009 15:48:31 GMT
what you are getting is an unformatted string, directly out of the database
in the sql query that creates the table row it appears some severe lack of
foresight has stored a string date instead of a timestamp,
if the timestamp were stored then date comparison is easier, select a range
of dates by simply numeric values,
output is easier, can be formatted to different user requirements even while
the information is displayed
the database is slightly smaller and faster, int compared to a text field.
and can format your date to that used, in the config files, for any user
redesign the database and the sql input at this early stage and less
problems later,
the output field can then be
<td>date(j-m-Y, %s)</td>
I have chosen 31d-12m-1999y, thats the way my calendar works, the date
strings are in the php online manual.
--
_ _
"Moose" <1911@xxxxxxxxxxx> wrote in message
news:250120091010497094%1911@xxxxxxxxxxxxxx
I'm a bit stumped on how to change the DATE format of the following SQL
query.
The code below works fine, but the results will show the date as
1999-01-01.
I would like to have the result be displayed as 01-01-1999.
So, is there a simple way to work with the %s formatting?
while ($myrow = mysql_fetch_row($result)) {
printf("
<tr>
<td>%s</td> <- This returns a date as 1999-01-01
<td>%s</td>
<td>%s</td>
<td>$%s</td>
<td>%s</td>
<td>%s</td>
</tr>\n",
$myrow[1], $myrow[2], $myrow[3],$myrow[4],$myrow[5],$myrow[6]);
}
echo "</table>\n";
.
- Prev by Date: Re: [PHP] New PHP User with a simple question
- Next by Date: Re: [PHP] Authentication by client certificate
- Previous by thread: [PHP] Captha Image Matching the Session Value.
- Next by thread: Re: [PhP - dB] About Formatting a Date Result
- Index(es):
Relevant Pages
|