Reformat Yahoo finance date?
I'm using http://finance.yahoo.com/d/quotes.csv?s= to grab a company's stock prices and imbedding in their site. I have 2 issues with it:
Is it possible to reformat the date? It's currently returned MM/DD/YYYY, and it would be great if I were able to reformat to return DD/MM/YYYY. Is this possible?
Also, the date is being returned with quotation marks, to literally return "MM/DD/YYY". I'd really love to get rid of these quotation marks.
Any ideas?
Many TIA!
EDIT:
I'm using the following code:
<?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.y开发者_JAVA技巧ahoo.com/d/quotes.csv?s=' . $asxcode . '.AX&f=d1');
echo '$' . $price . '<br/>' . $date;
?>
Try this:
//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);
精彩评论