-2

I want to insert date in dd mm yy format and this is my php script

date_default_timezone_set('Asia/Kolkata');

            $date = date('Y-m-d');

            $qry="INSERT INTO `nesbaty_offer`( `provider_id`, 
                                   `offer_punch`, 
                                   `offer_description`, 
                                   `terms`, 
                                   `sales_discount`, 
                                   `referal`, 
                                   `duration`, 
                                   `billing_type`, 
                                   `status`, 
                                   `service_location`, 
                                   `time`) VALUES('".$provider_id."',
                                   '".$offer_punch."',
                                   '".$offer_description."',
                                   '".$terms."',
                                   '".$sales_discount."',
                                   '".$referral."',
                                   '".$duration."',
                                   '".$billing_type."',
                                   '".$status."',
                                   '".$service_location."',
                                   '".$date."')";

Currently it is storing like this

YY-MM-DD
2018-05-22

But i want this

22-05-2018

Is it possible?

1 Answers1

1

You can't change the date format if you are using the date data-type in your database table.

But if you really want to change the format, I wold like to suggest using DATE_FORMAT

SELECT
DATE_FORMAT(column_name, '%m/%d/%Y')
FROM tablename;
Peter
  • 8,776
  • 6
  • 62
  • 95
Lavish Tyagi
  • 223
  • 5
  • 10