我有来自其他网站的废弃/获取html表数据的脚本。网站日期格式为26/8/2011,我如何将其更改为此格式2011-12-13 ??
function createRSSFile($tag,$value,$data)
{
# this will return the each element with tag.
$tag=strtolower(str_replace(" ","_",$tag));
$tag=strtolower(str_replace(":","",$tag));
$tag=strtolower(str_replace("&","and",$tag));
$returnITEM = "<".$tag.">".htmlspecialchars(str_replace(" 00:00:00","",$value))."</".$tag.">";
return $returnITEM;
}
function fetchData($jobid) {
$html=file_get_contents('http://acbar.org/JobDetail.aspx?id='.$jobid);
$html=str_replace("<td></td>", "",$html);
$html=str_replace("<td style=\"font-size:8pt;font-weight:bold;\"></td>","<td style=\"font-size:8pt;font-weight:bold;\">Null</td>",$html);
$html=str_replace("<td style=\"font-size:8pt;font-weight:bold;\" colspan=\"2\" ></td>","<td style=\"font-size:8pt;font-weight:bold;\" colspan=\"2\" >Null</td>",$html);
$html=str_replace(" ", " ",$html);
$html=str_replace("?", "<br>",$html);
$html=str_replace("<br>", "_br_",$html);
$dom = new DOMDocument;
$dom->loadHTML( $html );
//echo $dom->saveHTML();
//exit;
$rows = array();
foreach( $dom->getElementsByTagName( 'tr' ) as $tr ) {
$cells = array();
foreach( $tr->getElementsByTagName( 'td' ) as $td ) {
if(trim($td->nodeValue)!='')
$cells[] = str_replace("_br_","<br>",trim($td->nodeValue));
}
if(sizeof($cells)>0)
$rows[] = $cells;
}
答案 0 :(得分:0)
总是可以将日期传递给日期,然后按照您希望的日期格式化,就像这样......
$timeToModify = strtotime($passedTime);
$formattedTime = date("Y-m-D", $timeToModify);