2010-11-26 22 views
0

我使用http://finance.yahoo.com/d/quotes.csv?s=来获取公司的股票价格并嵌入他们的网站。我有2个问题:重新格式化雅虎财务日期?

  1. 是否可以重新格式化日期?它目前返回MM/DD/YYYY,如果我能够重新格式化以返回DD/MM/YYYY,那将会很好。这可能吗?

  2. 另外,日期将被返回引号,逐字地返回“MM/DD/YYY”。我真的很想摆脱这些引号。

任何想法?

很多TIA!


编辑:

我用下面的代码:

<?php 
$asxcode = 'TDO'; 
$price = file_get_contents('http://finance.yahoo.com/d/quotes.csv?s=' . $asxcode . '.AX&f=l1'); 
$date = file_get_contents('http://finance.yahoo.com/d/quotes.csv?s=' . $asxcode . '.AX&f=d1'); 
echo '$' . $price . '<br/>' . $date; 
?> 
+0

它有助于提供实际的URL和数据我们应该要看。 – 2010-11-26 03:32:30

+0

道歉 - 我以为这会比它更容易。 – circey 2010-11-26 03:42:42

回答

4

试试这个:

//get rid of the quotation marks 
$yahoo_date = trim($yahoo_date, '"'); 

//will recognize yahoo's format and convert to a timestamp 
$timestamp = strtotime($yahoo_date); 

//you can now format it in any way you want 
$reformatted_date = date('d/m/Y', $timestamp);