Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001011

Re: [PHP-DB] time from Mysql to php From: Glen Scott (glen <email protected>)
Date: 01/02/01

Hi Kevin,

At 16:32 29/12/00, Kevin McCarthy wrote:
>I have several tables that use a date field but for the life of me I can't
>figure how to use the values to show dates/times in various formats in PHP.
>
>The gist of it is, I capture timestamps in a MySQL record as
>'20001229162800'. I need to use this value to show a time/date in PHP but
>none of the PHP date/time functions seem to recognize this as a valid date
>string.
>
>Do I need to perform a conversion on this string in order to further
>format it in display?

How about using the MySQL function DATE_FORMAT:

examples:

SELECT DATE_FORMAT('1999-12-31 23:00:00', '%r on %W') would produce
11:00:00 PM on Friday

SELECT DATE_FORMAT('2001-11-05', '%D%M') would produce 5th November.

Check out
http://www.mysql.com/documentation/mysql/commented/manual.php?section=Date_and_time_functions
for more information.

Regards,

Glen

-----------------------------------------------------
   Design Solution Limited
   t: +44 (0)1502 513008
   f: +44 (0)1502 588622
   e: info <email protected>
   w: http://www.designsolution.co.uk
   Nouvotech House, Harbour Road,
   Oulton Broad, Suffolk, NR32 3LZ, UK
-----------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>