php-db | 2001011
Date: 12/29/00
- Next message: Dave Carrera: "[PHP-DB] Php, MySql dynamic creation of dropdown list"
- Previous message: Miles Thompson: "Re: [PHP-DB] time from Mysql to php"
- Next in thread: Glen Scott: "Re: [PHP-DB] time from Mysql to php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
You have many options:
1) User the substr() function to print the first 4 digits as the year, the
next 2 digits as the month, etc..
2) Use ereg_replace (regular expressions) to print the date. Here's an
example:
print
ereg_replace("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})","\\2/\\3/\\1
\\4:\\5:\\6", $datevariablefromdatabase);
if $datevariablefromdatabase = 20001229162800
then you will see: "12/29/2000 16:28:00"
Hope this helps
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?
>
> TIA.
>
> Kevin McCarthy Body & Soul
> http://www.bodynsoul.com
>
> --
> 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>
-- 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>
- Next message: Dave Carrera: "[PHP-DB] Php, MySql dynamic creation of dropdown list"
- Previous message: Miles Thompson: "Re: [PHP-DB] time from Mysql to php"
- Next in thread: Glen Scott: "Re: [PHP-DB] time from Mysql to php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

