2014-04-29 26 views
0

我有一个成员列表转储,其中有7000名用户使用unix时间戳格式的加入日期和订阅日期。问题是我需要将这些成员导入新的会员软件,并且日期格式为dd/mm/yyyy。现在,如果做了这样的转换使用从数据转储将多个unix时间戳转换为dd/mm/yyyy

$datetime = strtotime($row->createdate); 
$mysqldate = date("m/d/y g:i A", $datetime); 

但如何转换几乎14000这样的时间戳这是在单词串之间的单个值从MySQL数据库来?有什么我可以做或某种方式?

转储的部分

memberid,"identid","loginid","networkid","refurl_lookup_id","status","trial","joined","expired","last_login","stamp","siteid","username","password","cryptpass","ip","email","session","mailok","flat_price","first_login","third_party_partner_id","cascadeid","cascade_item_id","token","original_username","renamed","marked","token_hash","firstname","lastname","address1","address2","zip","city","country","state","shipping_firstname","shipping_lastname","shipping_address1","shipping_address2","shipping_zip","shipping_city","shipping_country","shipping_state","phone","xsell_success","xsell_message","custom1","custom2","custom3","custom4","custom5","last_modified","member_subscription_id","memberidx","billerid","statid","cost","cost_charge","spent","refunded","charges","next_rebill","optionid","rebills","active","upgradeid","expires","nats_expires","biller_expires","original_optionid","created_date","loginid_assigned","identid_assigned","gateway_token","campaignid","programid","tourid","adtoolid","subid1","subid2","countryid","promotionalid","loginid_nice" 
7719,"26","0","0","27426","1","0","1398029330","0","1398797388","1398029330","1","torsten55","netsrot55","9dlO.AEZY3LpY","44776524","sd[email protected]","79ab391dc0873b7e18c63637d10d4a41","1","0","1398029433","0","1","1","0","sdsd","0","0","fb1d7da87c445cdfb59f241bd7e29dfe","dsd","Dietz","Karl-Liebknecht-Ring 22","","01612","Nuenchritz","DE","XX","","","","","","","","","","0","","","","","","","0","9866","CCBILL:02141107010sdsd","1","553543b62e8977","0","571","3938","0","1","1400707730","2","0","1","","1400707730","1400707730","0","2","1398029154","0","0","","0","0","1","0","0","0","0","0","Type-In" 
7816,"45","0","0","30667","1","0","1398609314","0","1398797233","1398609314","1","Phantom183","MXU146","ac7Jo.tfvdJ5o","1573202729","[email protected]","c29c6032ed3867b70ec7ec25749a1fde","1","0","1398609530","0","1","1","0","rolex","0","0","9446bf3e08c2e628cf449756ba92a9cb","sddso","Nasdal","BAhnhofstraße","","03046","Cottbus","DE","XX","","","","","","","","","","0","","","","","","","0","10043","CCBILL:021411770100000sd","1","5535d1545cd3f9","0","380","2627","0","1","1401287714","1","0","1","","1401287714","1401287714","0","4","1398609221","0","0","","0","0","4","0","0","0","0","0","Type-In" 
+2

向我们展示了数据的一部分转储 –

+0

http://dev.mysql.com/doc /refman/5.5/en/date-and-time-functions.html#function_time-format –

+0

添加转储@JohnConde – user1001176

回答

0

大多只是从手动复制一个基本的例子:

if (($handle = fopen("olddump.csv", "r")) !== FALSE) { 
    $fp = fopen('newdump.csv', 'w'); 
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { 
     // Do this for each date field 
     $data[7] = date('d/m/Y', $data[7]); // joined 
     $data[9] = date('d/m/Y', $data[7]); // last_login 
     // etc... 

     fputcsv($fp, $data); 
    } 
    fclose($handle); 
    fclose($fp); 
} 
+0

感谢您的帮助,但我得到的错误,例如'遇到一个非格式良好的数值'和未定义的'offset' – user1001176