Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Need help with outputting dates

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Need help with outputting dates

Postby furiousweebee » Sat Mar 29, 2003 6:21 am

Hi. I'm a complete newbie in that I've never studied PHP in any way shape or form, let alone tried to write code. However I have pages on my site that have been written for me and I need to modify one particular part, so that it displays the date in this manner:

(eg) 21st October, 2003

I have data in tables in MySQL of course, so I'll just give you the functions I've got, and how I've used the date itself:

----------------------------

$sql = "SELECT id, date, name, comments
FROM $table_name
ORDER BY id
";

$result = @mysql_query($sql,$connection)
or die("Couldn't execute query.");


$num=mysql_numrows($result);
$k=($num-5);
$i=($num-1);
while ($k<$num) {

$date=mysql_result($result,$i,"date");
$name=mysql_result($result,$i,"name");
$comments=mysql_result($result,$i,"comments");
$yr=strval(substr($date,0,4));
$mo=strval(substr($date,5,2));
$da=strval(substr($date,8,2));
?>
</font> </font>
<table border="0" width="100%" align="center" cellpadding="2" cellspacing="2">
<tr>
<td valign="top"> <div align="justify"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><?echo "$da-$mo, $yr"; ?></b></font>
<br>
<font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><? echo "$comments"; ?></font></div></td>
</tr>
<?

--$i;
++$k;

}

?>

----------------------------

What do I need to do to change the date to appear in the way I mentioned above?

Any help would be greatly appreciated! Thanks in advance.
furiousweebee
New php-forum User
New php-forum User
 
Posts: 7
Joined: Fri Feb 14, 2003 10:10 pm

Postby TheIceman5 » Sat Mar 29, 2003 5:00 pm

think you need to go have a good read of php.net

heres the date function of theirs with detailed usage.

http://www.php.net/manual/en/function.date.php
TheIceman5
New php-forum User
New php-forum User
 
Posts: 28
Joined: Tue Jan 21, 2003 9:31 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.