可能重複比較:
How to convert date from one format to another如何兩個日期從數據庫中它得到的記錄從Excel
我有5列的電子表格。其中之一包含格式爲02-Dec-10的日期列。
當我喂的是Excel表單數據庫它存儲的空日期0000-00-00 0點零零分00秒
我如何可以將其存儲爲日期。 PLZ幫助
編輯1:
這是代碼使用養活數據數據庫CSV文件
$date = date("d-m-Y");
$databasetable = "sample";
$fieldseparator = ",";
$lineseparator = "\n";
$csvfile = "../uploads/" . basename($_FILES['file']['name']);
$addauto = 0;
$save = 1;
$outputfile = "../temp/output.sql";
if(!file_exists($csvfile)) {
#echo $csvfile;
echo "File not found. Make sure you specified the correct path.\n";
return 0;
exit;
}
$file = fopen($csvfile,"r");
if(!$file) {
#echo "Error opening data file.\n";
return 0;
exit;
}
$size = filesize($csvfile);
if(!$size) {
echo "File is empty.\n";
return 0;
exit;
}
$csvcontent = fread($file,$size);
fclose($file);
$lines = 0;
$queries = "";
$linearray = array();
foreach(split($lineseparator,$csvcontent) as $line) {
$lines++;
$line = trim($line," \t");
$line = str_replace("\r","",$line);
$line = str_replace("'","\'",$line);
$linearray = explode($fieldseparator,$line);
$linemysql = implode("','",$linearray);
if($addauto)
$query = "insert into $databasetable values('','$linemysql');";
else
$query = "insert into $databasetable values('$linemysql');";
$queries .= $query . "\n";
@mysql_query($query);
}
@mysql_close($con);
if($save) {
$file2 = fopen($outputfile,"w");
if(!$file2) {
echo "Error writing to the output file.\n";
return 0;
}
else {
fwrite($file2,$queries);
fclose($file2);
return 1;
}
}
//echo "Found a total of $lines records in this csv file.\n";
你在使用什麼樣的方法使用哪種類型的庫使用代碼來進入什麼樣的數據庫? – 2011-03-31 19:30:23
請停止發佈重複內容,特別是如果新內容與其他內容不太一樣,並且已經提供了大量幫助。 – 2011-03-31 19:31:19
這不是重複的隊友......我錯誤地發佈了這些問題。這個問題是無關的 – Rajasekar 2011-03-31 19:33:08