dbase date format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bouncer
Forum Contributor
Posts: 162
Joined: Wed Feb 28, 2007 10:31 am

dbase date format

Post by bouncer »

hi there.

when i get a record from a date field in a .dbf file is like this yyyymmdd, is there anyway to get it like this, yyyy-mm-dd ?

thanks in advance
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: dbase date format

Post by Zoxive »

http://dev.mysql.com/doc/refman/5.0/en/ ... ate-format

Code: Select all

SELECT DATE_FORMAT(mydatefld,'%Y-%m-%d') AS date FROM `stuff`
bouncer
Forum Contributor
Posts: 162
Joined: Wed Feb 28, 2007 10:31 am

Re: dbase date format

Post by bouncer »

i'm reading a .dbf file, so i think that doesn't work.

Code: Select all

 
$dbase = dbase_open('sys_inf.dbf', 0) or die (error());
$record_numbers = dbase_numrecords( $dbase);
    for ($i = 1; $i <= $record_numbers; $i++) {
        $row = dbase_get_record_with_names($dbase, $i);
        echo $row['SYSDATE'];     // ---> 20070910  and i need, 2007-09-10
    }
dbase_close( $dbase );
 
thanks in advance
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: dbase date format

Post by Zoxive »

Code: Select all

$row['SYSDATE'] = date('Y-m-d',strotime($row['SYSDATE'];));
bouncer
Forum Contributor
Posts: 162
Joined: Wed Feb 28, 2007 10:31 am

Re: dbase date format

Post by bouncer »

thanks, that solve my problem. :D

regards
Post Reply