Re: [PhP - dB] About Formatting a Date Result



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";


.



Relevant Pages

  • Re: [PHP] Date/time format?
    ... Jason Pruim wrote: ... I am trying to figure out what format a string is in in a database. ... Below is an example of one of the lines in the database, What I'm really interested in is how it represents the "day". ... I have not been able to find ANY info about that format, other then other people using it in blogs. ...
    (php.general)
  • Re: year to date conversion
    ... the date in ISO-format, i.e. exactly in the format the OP requested. ... It is rare to need to be database independent. ... Sure, but again, there are moments, where a PreparedStatement ... The string is created by java.sql.Date, ...
    (comp.lang.java.programmer)
  • Re: Noob question on how to use an insert query in a command button
    ... in mm/dd/yyyy format (regardless of what your Short Date format have been ... Dim dbLocation 'Location of our Access database file ... Set objADO = CreateObject'Create an ADO connection ... objADO.Execute 'Execute this SQL query ...
    (microsoft.public.access.forms)
  • Re: [PhP - dB] About Formatting a Date Result
    ... In the MySQL database the field is set to date not timestamp as you ... foresight has stored a string date instead of a timestamp, ... and can format your date to that used, in the config files, for any user ...
    (php.general)
  • Re: Getting entries from an SQL database with datetime parameter
    ... format is what you want. ... funtion to convert date string into date time accordig to your needs. ... your database, you will run into troubles comparing date to string. ... > hard coded a query to populate the datagrid, ...
    (microsoft.public.dotnet.framework.adonet)