How to display Date only in PHP?
datetime, php
Solution
You can try this `date('Y:m:d', strtotime($date));`
Problem
How to display date only(without time) with format (Y:m:d) for table Return Date? When I choose the date in sql, it'll view as picture1(eg: 2012-04-10), after I save and display back it'll view as picture2(eg: Apr 10 2012 12:00:00). I would like to how to display as(eg: 2012-04-10) not display as (eg: Apr 10 2012 12:00:00) in table Return Date. Thanks Picture 1 Picture 2 under 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>"; } ``` Under 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"; } ```