Re: getdate - how to format date back from mysql db
| From: | scottrus at ipass dot net | Date: | Thu, 14 Sep 2000 02:53:18 +0000 |
| Subject: | Re: getdate - how to format date back from mysql db | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16755@lists.php.net to get a copy of this message | ||
When you query your MySQL db pull the date column from the table like this:
select l_name, f_name, unix_timestamp(survey_date) as survey_date from mytable;
This returns the data from your MySQL date field as a unix timestamp which
can be used in several php functions without further conversion.
Then use the date() command to build your date output any way you like.
Use the result from the survey_date column as the second argument in
the date() function.
echo date("Y-m-d",$survey_date);
Of course you'll have to go through the whole deal of getting
each value out of the MySQL results but it sounds like you've got
that part down since you are seeing results for $l_name and $f_name.
-- Scott
On Thu, Sep 14, 2000 at 10:35:53AM +1000, Jason wrote:
> hi all
> i have a survey page that is writing a date to a mysql db when the user
> fills out the survey....i use
> $add_date = date("Y-m-d G:i:s");
>
> which writes it to the db in a standard format...
>
> the problem i have is reading it back in php when i want to check on the
> survey results...
>
> so i want it to read to screen the name of the person and what time/date
> they took the survey..
>
> echo "<TD><font face=Verdana, Arial, Helvetica, sans-serif size=1 color =
> #000000>$f_name $l_name did the survey on $add_date
> </font></TD></TR>";
>
> Jason Savidge did the survey on 14th September 2000 at 9.05pm
>
> i have tried getdate() and tried to use the foreach function but just keep
> getting back "Array" instead of the info...
>
> can anyone suggest a fix or another way...i'm sure there must be an easier
> way!!
>
> many thanks
>
>
> Regards
> Jason
> IT Manager
> Brisbane Australia
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Scott