如何僅使用格式(Y:m:d)爲表格返回日期顯示日期(無時間)?當我在sql中選擇日期時,它會以picture1的形式顯示(例如:2012-04-10),保存並顯示後,它會查看爲圖片2(例如:Apr 10 2012 12:00:00)。我想如何在表格返回日期顯示爲(例如:2012-04-10)不顯示爲(例如:Apr 10 2012 12:00:00)。感謝如何僅在PHP中顯示日期?
圖片1
圖片2
下Result.php
$query = "SELECT ....BE.[batch_id],BED.[ReturnDate]
FROM .... as BE
INNER JOIN .... as BED
ON BE.[batch_exception_id] = BED.[batch_exception_id]
WHERE BE.[process_date_time] between '$date1' and '$date2'";
while ($row = mssql_fetch_assoc($result)) {
$rDate = $row['ReturnDate'];
$beID = $row['batch_exception_id'];
$proc_dt = $row['process_date_time'];
$batchid = $row['batch_id'];
echo "<tr>";
echo "<td>" . $beID . "<input type='hidden' name='beID[$i]' value='$beID'/></td>";
echo "<td>" . $batchid . "<input type='hidden' name='batchid[$i]' value='$batchid'/></td>";
echo "<td>" . $proc_dt . "<input type='hidden' name='procDT[$i]' value='$proc_dt'/></td>";
echo "<td>";
$date="date[".$i."]";
echo "<input type='text' name='date[$i]' id='$date' value='$rDate' onclick=\"fPopCalendar('".$date."')\">";
$i++;
echo "</td>";
echo "</tr>";
}
在Save.php
//Select database
$selected = mssql_select_db($myDB, $link)or die("Couldn't open database $myDB");
for ($i=0; $i<$tot_rec;$i++) {
$ret_date=trim($arrretDate[$i]);
ECHO "$ret_date<br>";
if (strlen($ret_date)>0) {
$query = "UPDATE .....
SET [ReturnDate] = '$ret_date'
WHERE [batch_exception_id]= '$arrbeID[$i]'";
$result = mssql_query($query);}
}
//execute the SQL query
if ($result){
header("Location:....");}
else{
echo "Error Save";
}
看一看這裏http://php.net/manual/en/class.datetime。 php – wgcrouch 2012-04-19 11:03:25
你想要做什麼?什麼是輸入日期格式,你想得到什麼? – 2012-04-19 11:06:07
只是編輯的問題,並做了不好的解釋道歉 – srahifah 2012-04-20 01:43:49