RE: [PHP] dates from db
| From: | Eric Naujock | Date: | Wed, 07 Mar 2001 14:41:36 +0000 |
| Subject: | RE: [PHP] dates from db | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-42904@lists.php.net to get a copy of this message | ||
My own solution to this is a bit more complex but it seems to work with both of the databases I work
with. MySQL and Postgress.
for example I would use 'select *,unix_timestamp(cr_date) as my_cr_date from table where
ref_index=2345;'
Then when I go to output it I can use the unix date command such as
'$string=date("l dS of F Y h:i:s A",db->f(my_cr_date));
My reference to db->f(my_cr_date) is my phplib methof of reading the data. You may use your own
method. Doing it this way you can get your own method of displaying dates or times in almost any way
you want. And you don;t have to count on your database supporting it.
>>> "Mark Roedel" <MarkRoedel@letu.edu> 03/07/01 09:08AM >>>
> -----Original Message-----
> From: Matt Davis [mailto:matt@roundyourway.co.uk]
> Sent: Wednesday, March 07, 2001 7:35 AM
> To: Php Mailing List
> Subject: [PHP] dates from db
>
>
> I am calling on a number of fields from my db one of which is
> a date. When the date displays it is in the following format
>
> YYYY-MM-DD 00:00:00
>
> I Want it to only display the date and not the time like this
>
> YYYY-MM-DD
>
> Is it possible to remove the time when calling on it from the db
Check the documentation for the database engine you're using.
MySQL, for example, has a date_format() function that you can use in
your query to specify what information you'd like displayed from a
date/time field, and how you'd like it presented.
---
Mark Roedel (roedelm@letu.edu) || "There cannot be a crisis next week.
Systems Programmer / WebMaster || My schedule is already full."
LeTourneau University || -- Henry Kissinger
--
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