Re: datetime formatting problem
| From: | Daniel Clark | Date: | Fri, 28 May 2004 19:44:18 +0000 |
| Subject: | Re: datetime formatting problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-187162@lists.php.net to get a copy of this message | ||
Isn't "date" a reserved word?
> hi all -
>
> this is probably straight forward, but i'm learning and would appreciate
> any insight.
>
> i'm using the datetime type in mysql and have been able to successsfully
> pull the data records's date, but it's failing out and giving me the
> current time [as in what it says on my system's clock]
>
> basically i'm just spitting out all the rows to an html table and would
> like to have the date AND time formatted as is in the date(...) function
> at the top of the code demo.
>
> thanks!
> matt
>
> ///// begin code demo
>
>
> function formatDate($val)
> {
> $arr = explode("-", $val);
> return date("M d, Y g:i A", mktime(0,0,0, $arr[1], $arr[2], $arr[0]));
> }
>
>
> // open database connection
> $connection = mysql_connect($host, $user, $pass) or die ("Unable to
> connect!");
>
> // select database
> mysql_select_db($db) or die ("Unable to select database!");
>
> // generate and execute query
> $query = "SELECT * FROM outdoor ORDER BY id ASC";
> $result = mysql_query($query) or die ("Error in query: $query. " .
> mysql_error());
>
>
> // if records present
> if (mysql_num_rows($result) > 0)
> {
> // iterate through resultset
> // print title with links to edit and delete scripts
> while($row = mysql_fetch_object($result))
> {
> ?>
> <tr>
> <td><? echo $row->id; ?></td>
> <td><? echo $row->name; ?></td>
> <td><a href="mailto:<? echo $row->email;
> ?>"><? echo
> $row->email; ?></a></td>
> <td><? echo $row->zip ?></td>
> <td><? echo formatDate($row->date); ?></td>
> <td><? echo $row->club_member ?></td>
> <td><? echo $row->driver ?></td>
> <!-- <td><font size="-1"><? echo $row->active
> ?></font></td> -->
>
> <td><center><a href="edit.php?id=<? echo $row->id;
> ?>"><img
> src="notepad.gif" alt="" width="16" height="16"
> border="0"></a>
> <a href="delete.php?id=<? echo $row->id; ?>"><img
> src="trashcan.gif"
> alt="" width="16" height="16"
> border="0"></a></center></td>
> </tr>
> <?
> }
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>