-5

Possible Duplicate:
Format mysql datetime with php

I have this query:

$sql="SELECT job_id,job,job2,start_date,end_date ".
     "FROM pianificazione WHERE job_id='$selected_jobs'";

the end-date is in a DATE format in the database, but i need to print it in d-m-Y format Here is where i print it:

echo "<td><input type='text'id='end_date'  class='datepicker'  ".
         "title='D-MMM-YYYY' name='end_date[$i]' value='".
          $rows['end_date']. "' /></td>";

Could you please help me with this? Thanks..

Community
  • 1
  • 1
Tao
  • 85
  • 3
  • 7

3 Answers3

4

You can directly use in mysql query

DATE_FORMAT(end_date,'%d-%m-%Y')

Updated:

DATE_FORMAT(end_date,'%d-%m-%Y') as end_date
iLaYa ツ
  • 3,941
  • 3
  • 32
  • 48
0

To convert your DATE format $date to a d-m-Y format date use PHPs date() function like this:

$date = date("d-m-Y", strtotime($date));
Zulakis
  • 7,859
  • 10
  • 42
  • 67
-3
$date = substr($date_original, 8, 2).'-'.substr($date_original, 5, 2).'-'.substr($date_original, 0, 4);
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
abidibo
  • 4,175
  • 2
  • 25
  • 33