Change date format (in DB or output) to dd/mm/yyyy - PHP MySQL





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







12















MySQL stores the date in my database (by default) as 'YYYY-MM-DD' The field type for my date is 'DATE' (I do not need any time storage).. Is there a simple way to change it by default to DD/MM/YYYY ?



I call up different dates in 2 different tables, and no where in any of my code do I have anything resembling a date variable or anything! Hopefully this is a straight forward change?










share|improve this question































    12















    MySQL stores the date in my database (by default) as 'YYYY-MM-DD' The field type for my date is 'DATE' (I do not need any time storage).. Is there a simple way to change it by default to DD/MM/YYYY ?



    I call up different dates in 2 different tables, and no where in any of my code do I have anything resembling a date variable or anything! Hopefully this is a straight forward change?










    share|improve this question



























      12












      12








      12


      2






      MySQL stores the date in my database (by default) as 'YYYY-MM-DD' The field type for my date is 'DATE' (I do not need any time storage).. Is there a simple way to change it by default to DD/MM/YYYY ?



      I call up different dates in 2 different tables, and no where in any of my code do I have anything resembling a date variable or anything! Hopefully this is a straight forward change?










      share|improve this question
















      MySQL stores the date in my database (by default) as 'YYYY-MM-DD' The field type for my date is 'DATE' (I do not need any time storage).. Is there a simple way to change it by default to DD/MM/YYYY ?



      I call up different dates in 2 different tables, and no where in any of my code do I have anything resembling a date variable or anything! Hopefully this is a straight forward change?







      php mysql sql date






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 27 '13 at 18:07









      John Conde

      187k80376430




      187k80376430










      asked Mar 19 '10 at 19:53









      JessJess

      86117




      86117
























          8 Answers
          8






          active

          oldest

          votes


















          19














          In PHP, you could :




          • Transform the date to a timestamp, using strtotime

          • Format it, using date


          A bit like this, I'd say :



          $timestamp = strtotime($date_from_db);
          echo date('d/m/Y', $timestamp);


          But this will only work for dates between 1970 and 2038, as timestamps are stored as 32 bits integers, counting from 1970-01-01.





          In MySQL, I suppose the date_format function would do the trick.

          For example :



          mysql> select date_format(curdate(), '%d/%m/%Y');
          +------------------------------------+
          | date_format(curdate(), '%d/%m/%Y') |
          +------------------------------------+
          | 19/03/2010 |
          +------------------------------------+
          1 row in set (0.03 sec)




          And, for the sake of completness, another solution, in PHP, that doesn't suffer from the limitation of 1970-2038 would be to use the DateTime class, and, especially :





          • DateTime::__construct to parse the date returned by the DB


          • DateTime::format to format the date to whatever format you want.


          For example, this portion of code :



          $date = new DateTime('2010-03-19');
          echo $date->format('d/m/Y');


          would get you this output :



          19/03/2010





          share|improve this answer
























          • Where do I use this date function and how?

            – Jess
            Mar 19 '10 at 19:58











          • I've edited my answer to add more informations ; is your comment-question still valid ? If yes, which possible solution does "this date function" refer to ?

            – Pascal MARTIN
            Mar 19 '10 at 20:02











          • I'm just a bit confused where I insert it! :S Sorry, I'll have have a play and work it out :)

            – Jess
            Mar 19 '10 at 20:12











          • If you choose one of the PHP solutions, you can do that somewhere arround your display, as it's a matter of presentation ;;; if you choose the SQL solution, well, obvisouly, you'll do that in your SQL query (But considering this is presentation, I would prefer having this in the view/template, in PHP)

            – Pascal MARTIN
            Mar 19 '10 at 20:14











          • Ok, what would you say is the best solution to use if I am planning on sorting the table rows by date (afterwards), and also running a query that displays items with dates that have passed a deadline, from what the system date is (if that makes sense)... e.g. system date is set as 20th march 2010, a deadline for activity is set as 21st march...i plan on changing the colour of the table row to red (just an example) to shows its passed date! Will using PHP or MySQL to format the date make any difference to my requirment?

            – Jess
            Mar 19 '10 at 20:25



















          4














          Just use the Mysql built in function DATE_FORMAT()



          SELECT DATE_FORMAT(some_date_field, "Y/m/d");





          share|improve this answer



















          • 1





            This, except the format is wrong in the example. :)

            – Mikael S
            Mar 19 '10 at 20:06











          • @MikaelS which is the correct?

            – candlejack
            Apr 14 '17 at 5:25



















          2














          You can display you date in any format you want in your pages, in mysql i realy don't know, in php you can use this function: date ( string $format [, int $timestamp ] ). So you can do this:



          echo date( "d/m/Y", strtotime ( $your_date ) );



          You can find full description here: http://php.net/manual/en/function.date.php






          share|improve this answer































            1














            After getting it from the DB, use $time = strtotime($value) to convert it to a timestamp in PHP. Then use date("d/m/Y", $time) to get it in that format.






            share|improve this answer































              1














              If you used some Framework like Zend, it would be very easy because you have plenty of classes to handle databases and date formatting. Then you would always see the output as the Brazilian date format. Just like Delphi TDateField uses Windows date format in the current computer, Zend will look up in your own configuration.






              share|improve this answer































                1














                i'm using this script and put it on upper line.



                $(function(){
                var pickerOpts = {
                dateFormat: "yy-mm-dd"
                };
                $("#datepicker").datepicker(pickerOpts);
                });


                and this one in your form.



                <input id=**"datepicker" type="date"** name="Start"  size="9" value="<?php  

                echo $Start;

                ?>" />


                It will appear as d/m/y on your page but in your database y/m/d.






                share|improve this answer

































                  0














                  This mysql function will return the correct format in the result



                  SELECT DATE_FORMAT(date_field, "%M %d %Y");





                  share|improve this answer































                    0














                    $dtShowDate = $_POST['dtShowDate'];
                    $date =explode('-', $dtShowDate)0;
                    $showdate = $date[2]."-".$date[0]."-".$date[1];



                    Set Date as per your need






                    share|improve this answer


























                      Your Answer






                      StackExchange.ifUsing("editor", function () {
                      StackExchange.using("externalEditor", function () {
                      StackExchange.using("snippets", function () {
                      StackExchange.snippets.init();
                      });
                      });
                      }, "code-snippets");

                      StackExchange.ready(function() {
                      var channelOptions = {
                      tags: "".split(" "),
                      id: "1"
                      };
                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                      StackExchange.using("externalEditor", function() {
                      // Have to fire editor after snippets, if snippets enabled
                      if (StackExchange.settings.snippets.snippetsEnabled) {
                      StackExchange.using("snippets", function() {
                      createEditor();
                      });
                      }
                      else {
                      createEditor();
                      }
                      });

                      function createEditor() {
                      StackExchange.prepareEditor({
                      heartbeatType: 'answer',
                      autoActivateHeartbeat: false,
                      convertImagesToLinks: true,
                      noModals: true,
                      showLowRepImageUploadWarning: true,
                      reputationToPostImages: 10,
                      bindNavPrevention: true,
                      postfix: "",
                      imageUploader: {
                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                      allowUrls: true
                      },
                      onDemand: true,
                      discardSelector: ".discard-answer"
                      ,immediatelyShowMarkdownHelp:true
                      });


                      }
                      });














                      draft saved

                      draft discarded


















                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f2480186%2fchange-date-format-in-db-or-output-to-dd-mm-yyyy-php-mysql%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown

























                      8 Answers
                      8






                      active

                      oldest

                      votes








                      8 Answers
                      8






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      19














                      In PHP, you could :




                      • Transform the date to a timestamp, using strtotime

                      • Format it, using date


                      A bit like this, I'd say :



                      $timestamp = strtotime($date_from_db);
                      echo date('d/m/Y', $timestamp);


                      But this will only work for dates between 1970 and 2038, as timestamps are stored as 32 bits integers, counting from 1970-01-01.





                      In MySQL, I suppose the date_format function would do the trick.

                      For example :



                      mysql> select date_format(curdate(), '%d/%m/%Y');
                      +------------------------------------+
                      | date_format(curdate(), '%d/%m/%Y') |
                      +------------------------------------+
                      | 19/03/2010 |
                      +------------------------------------+
                      1 row in set (0.03 sec)




                      And, for the sake of completness, another solution, in PHP, that doesn't suffer from the limitation of 1970-2038 would be to use the DateTime class, and, especially :





                      • DateTime::__construct to parse the date returned by the DB


                      • DateTime::format to format the date to whatever format you want.


                      For example, this portion of code :



                      $date = new DateTime('2010-03-19');
                      echo $date->format('d/m/Y');


                      would get you this output :



                      19/03/2010





                      share|improve this answer
























                      • Where do I use this date function and how?

                        – Jess
                        Mar 19 '10 at 19:58











                      • I've edited my answer to add more informations ; is your comment-question still valid ? If yes, which possible solution does "this date function" refer to ?

                        – Pascal MARTIN
                        Mar 19 '10 at 20:02











                      • I'm just a bit confused where I insert it! :S Sorry, I'll have have a play and work it out :)

                        – Jess
                        Mar 19 '10 at 20:12











                      • If you choose one of the PHP solutions, you can do that somewhere arround your display, as it's a matter of presentation ;;; if you choose the SQL solution, well, obvisouly, you'll do that in your SQL query (But considering this is presentation, I would prefer having this in the view/template, in PHP)

                        – Pascal MARTIN
                        Mar 19 '10 at 20:14











                      • Ok, what would you say is the best solution to use if I am planning on sorting the table rows by date (afterwards), and also running a query that displays items with dates that have passed a deadline, from what the system date is (if that makes sense)... e.g. system date is set as 20th march 2010, a deadline for activity is set as 21st march...i plan on changing the colour of the table row to red (just an example) to shows its passed date! Will using PHP or MySQL to format the date make any difference to my requirment?

                        – Jess
                        Mar 19 '10 at 20:25
















                      19














                      In PHP, you could :




                      • Transform the date to a timestamp, using strtotime

                      • Format it, using date


                      A bit like this, I'd say :



                      $timestamp = strtotime($date_from_db);
                      echo date('d/m/Y', $timestamp);


                      But this will only work for dates between 1970 and 2038, as timestamps are stored as 32 bits integers, counting from 1970-01-01.





                      In MySQL, I suppose the date_format function would do the trick.

                      For example :



                      mysql> select date_format(curdate(), '%d/%m/%Y');
                      +------------------------------------+
                      | date_format(curdate(), '%d/%m/%Y') |
                      +------------------------------------+
                      | 19/03/2010 |
                      +------------------------------------+
                      1 row in set (0.03 sec)




                      And, for the sake of completness, another solution, in PHP, that doesn't suffer from the limitation of 1970-2038 would be to use the DateTime class, and, especially :





                      • DateTime::__construct to parse the date returned by the DB


                      • DateTime::format to format the date to whatever format you want.


                      For example, this portion of code :



                      $date = new DateTime('2010-03-19');
                      echo $date->format('d/m/Y');


                      would get you this output :



                      19/03/2010





                      share|improve this answer
























                      • Where do I use this date function and how?

                        – Jess
                        Mar 19 '10 at 19:58











                      • I've edited my answer to add more informations ; is your comment-question still valid ? If yes, which possible solution does "this date function" refer to ?

                        – Pascal MARTIN
                        Mar 19 '10 at 20:02











                      • I'm just a bit confused where I insert it! :S Sorry, I'll have have a play and work it out :)

                        – Jess
                        Mar 19 '10 at 20:12











                      • If you choose one of the PHP solutions, you can do that somewhere arround your display, as it's a matter of presentation ;;; if you choose the SQL solution, well, obvisouly, you'll do that in your SQL query (But considering this is presentation, I would prefer having this in the view/template, in PHP)

                        – Pascal MARTIN
                        Mar 19 '10 at 20:14











                      • Ok, what would you say is the best solution to use if I am planning on sorting the table rows by date (afterwards), and also running a query that displays items with dates that have passed a deadline, from what the system date is (if that makes sense)... e.g. system date is set as 20th march 2010, a deadline for activity is set as 21st march...i plan on changing the colour of the table row to red (just an example) to shows its passed date! Will using PHP or MySQL to format the date make any difference to my requirment?

                        – Jess
                        Mar 19 '10 at 20:25














                      19












                      19








                      19







                      In PHP, you could :




                      • Transform the date to a timestamp, using strtotime

                      • Format it, using date


                      A bit like this, I'd say :



                      $timestamp = strtotime($date_from_db);
                      echo date('d/m/Y', $timestamp);


                      But this will only work for dates between 1970 and 2038, as timestamps are stored as 32 bits integers, counting from 1970-01-01.





                      In MySQL, I suppose the date_format function would do the trick.

                      For example :



                      mysql> select date_format(curdate(), '%d/%m/%Y');
                      +------------------------------------+
                      | date_format(curdate(), '%d/%m/%Y') |
                      +------------------------------------+
                      | 19/03/2010 |
                      +------------------------------------+
                      1 row in set (0.03 sec)




                      And, for the sake of completness, another solution, in PHP, that doesn't suffer from the limitation of 1970-2038 would be to use the DateTime class, and, especially :





                      • DateTime::__construct to parse the date returned by the DB


                      • DateTime::format to format the date to whatever format you want.


                      For example, this portion of code :



                      $date = new DateTime('2010-03-19');
                      echo $date->format('d/m/Y');


                      would get you this output :



                      19/03/2010





                      share|improve this answer













                      In PHP, you could :




                      • Transform the date to a timestamp, using strtotime

                      • Format it, using date


                      A bit like this, I'd say :



                      $timestamp = strtotime($date_from_db);
                      echo date('d/m/Y', $timestamp);


                      But this will only work for dates between 1970 and 2038, as timestamps are stored as 32 bits integers, counting from 1970-01-01.





                      In MySQL, I suppose the date_format function would do the trick.

                      For example :



                      mysql> select date_format(curdate(), '%d/%m/%Y');
                      +------------------------------------+
                      | date_format(curdate(), '%d/%m/%Y') |
                      +------------------------------------+
                      | 19/03/2010 |
                      +------------------------------------+
                      1 row in set (0.03 sec)




                      And, for the sake of completness, another solution, in PHP, that doesn't suffer from the limitation of 1970-2038 would be to use the DateTime class, and, especially :





                      • DateTime::__construct to parse the date returned by the DB


                      • DateTime::format to format the date to whatever format you want.


                      For example, this portion of code :



                      $date = new DateTime('2010-03-19');
                      echo $date->format('d/m/Y');


                      would get you this output :



                      19/03/2010






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 19 '10 at 19:57









                      Pascal MARTINPascal MARTIN

                      341k59589616




                      341k59589616













                      • Where do I use this date function and how?

                        – Jess
                        Mar 19 '10 at 19:58











                      • I've edited my answer to add more informations ; is your comment-question still valid ? If yes, which possible solution does "this date function" refer to ?

                        – Pascal MARTIN
                        Mar 19 '10 at 20:02











                      • I'm just a bit confused where I insert it! :S Sorry, I'll have have a play and work it out :)

                        – Jess
                        Mar 19 '10 at 20:12











                      • If you choose one of the PHP solutions, you can do that somewhere arround your display, as it's a matter of presentation ;;; if you choose the SQL solution, well, obvisouly, you'll do that in your SQL query (But considering this is presentation, I would prefer having this in the view/template, in PHP)

                        – Pascal MARTIN
                        Mar 19 '10 at 20:14











                      • Ok, what would you say is the best solution to use if I am planning on sorting the table rows by date (afterwards), and also running a query that displays items with dates that have passed a deadline, from what the system date is (if that makes sense)... e.g. system date is set as 20th march 2010, a deadline for activity is set as 21st march...i plan on changing the colour of the table row to red (just an example) to shows its passed date! Will using PHP or MySQL to format the date make any difference to my requirment?

                        – Jess
                        Mar 19 '10 at 20:25



















                      • Where do I use this date function and how?

                        – Jess
                        Mar 19 '10 at 19:58











                      • I've edited my answer to add more informations ; is your comment-question still valid ? If yes, which possible solution does "this date function" refer to ?

                        – Pascal MARTIN
                        Mar 19 '10 at 20:02











                      • I'm just a bit confused where I insert it! :S Sorry, I'll have have a play and work it out :)

                        – Jess
                        Mar 19 '10 at 20:12











                      • If you choose one of the PHP solutions, you can do that somewhere arround your display, as it's a matter of presentation ;;; if you choose the SQL solution, well, obvisouly, you'll do that in your SQL query (But considering this is presentation, I would prefer having this in the view/template, in PHP)

                        – Pascal MARTIN
                        Mar 19 '10 at 20:14











                      • Ok, what would you say is the best solution to use if I am planning on sorting the table rows by date (afterwards), and also running a query that displays items with dates that have passed a deadline, from what the system date is (if that makes sense)... e.g. system date is set as 20th march 2010, a deadline for activity is set as 21st march...i plan on changing the colour of the table row to red (just an example) to shows its passed date! Will using PHP or MySQL to format the date make any difference to my requirment?

                        – Jess
                        Mar 19 '10 at 20:25

















                      Where do I use this date function and how?

                      – Jess
                      Mar 19 '10 at 19:58





                      Where do I use this date function and how?

                      – Jess
                      Mar 19 '10 at 19:58













                      I've edited my answer to add more informations ; is your comment-question still valid ? If yes, which possible solution does "this date function" refer to ?

                      – Pascal MARTIN
                      Mar 19 '10 at 20:02





                      I've edited my answer to add more informations ; is your comment-question still valid ? If yes, which possible solution does "this date function" refer to ?

                      – Pascal MARTIN
                      Mar 19 '10 at 20:02













                      I'm just a bit confused where I insert it! :S Sorry, I'll have have a play and work it out :)

                      – Jess
                      Mar 19 '10 at 20:12





                      I'm just a bit confused where I insert it! :S Sorry, I'll have have a play and work it out :)

                      – Jess
                      Mar 19 '10 at 20:12













                      If you choose one of the PHP solutions, you can do that somewhere arround your display, as it's a matter of presentation ;;; if you choose the SQL solution, well, obvisouly, you'll do that in your SQL query (But considering this is presentation, I would prefer having this in the view/template, in PHP)

                      – Pascal MARTIN
                      Mar 19 '10 at 20:14





                      If you choose one of the PHP solutions, you can do that somewhere arround your display, as it's a matter of presentation ;;; if you choose the SQL solution, well, obvisouly, you'll do that in your SQL query (But considering this is presentation, I would prefer having this in the view/template, in PHP)

                      – Pascal MARTIN
                      Mar 19 '10 at 20:14













                      Ok, what would you say is the best solution to use if I am planning on sorting the table rows by date (afterwards), and also running a query that displays items with dates that have passed a deadline, from what the system date is (if that makes sense)... e.g. system date is set as 20th march 2010, a deadline for activity is set as 21st march...i plan on changing the colour of the table row to red (just an example) to shows its passed date! Will using PHP or MySQL to format the date make any difference to my requirment?

                      – Jess
                      Mar 19 '10 at 20:25





                      Ok, what would you say is the best solution to use if I am planning on sorting the table rows by date (afterwards), and also running a query that displays items with dates that have passed a deadline, from what the system date is (if that makes sense)... e.g. system date is set as 20th march 2010, a deadline for activity is set as 21st march...i plan on changing the colour of the table row to red (just an example) to shows its passed date! Will using PHP or MySQL to format the date make any difference to my requirment?

                      – Jess
                      Mar 19 '10 at 20:25













                      4














                      Just use the Mysql built in function DATE_FORMAT()



                      SELECT DATE_FORMAT(some_date_field, "Y/m/d");





                      share|improve this answer



















                      • 1





                        This, except the format is wrong in the example. :)

                        – Mikael S
                        Mar 19 '10 at 20:06











                      • @MikaelS which is the correct?

                        – candlejack
                        Apr 14 '17 at 5:25
















                      4














                      Just use the Mysql built in function DATE_FORMAT()



                      SELECT DATE_FORMAT(some_date_field, "Y/m/d");





                      share|improve this answer



















                      • 1





                        This, except the format is wrong in the example. :)

                        – Mikael S
                        Mar 19 '10 at 20:06











                      • @MikaelS which is the correct?

                        – candlejack
                        Apr 14 '17 at 5:25














                      4












                      4








                      4







                      Just use the Mysql built in function DATE_FORMAT()



                      SELECT DATE_FORMAT(some_date_field, "Y/m/d");





                      share|improve this answer













                      Just use the Mysql built in function DATE_FORMAT()



                      SELECT DATE_FORMAT(some_date_field, "Y/m/d");






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 19 '10 at 19:56









                      John CondeJohn Conde

                      187k80376430




                      187k80376430








                      • 1





                        This, except the format is wrong in the example. :)

                        – Mikael S
                        Mar 19 '10 at 20:06











                      • @MikaelS which is the correct?

                        – candlejack
                        Apr 14 '17 at 5:25














                      • 1





                        This, except the format is wrong in the example. :)

                        – Mikael S
                        Mar 19 '10 at 20:06











                      • @MikaelS which is the correct?

                        – candlejack
                        Apr 14 '17 at 5:25








                      1




                      1





                      This, except the format is wrong in the example. :)

                      – Mikael S
                      Mar 19 '10 at 20:06





                      This, except the format is wrong in the example. :)

                      – Mikael S
                      Mar 19 '10 at 20:06













                      @MikaelS which is the correct?

                      – candlejack
                      Apr 14 '17 at 5:25





                      @MikaelS which is the correct?

                      – candlejack
                      Apr 14 '17 at 5:25











                      2














                      You can display you date in any format you want in your pages, in mysql i realy don't know, in php you can use this function: date ( string $format [, int $timestamp ] ). So you can do this:



                      echo date( "d/m/Y", strtotime ( $your_date ) );



                      You can find full description here: http://php.net/manual/en/function.date.php






                      share|improve this answer




























                        2














                        You can display you date in any format you want in your pages, in mysql i realy don't know, in php you can use this function: date ( string $format [, int $timestamp ] ). So you can do this:



                        echo date( "d/m/Y", strtotime ( $your_date ) );



                        You can find full description here: http://php.net/manual/en/function.date.php






                        share|improve this answer


























                          2












                          2








                          2







                          You can display you date in any format you want in your pages, in mysql i realy don't know, in php you can use this function: date ( string $format [, int $timestamp ] ). So you can do this:



                          echo date( "d/m/Y", strtotime ( $your_date ) );



                          You can find full description here: http://php.net/manual/en/function.date.php






                          share|improve this answer













                          You can display you date in any format you want in your pages, in mysql i realy don't know, in php you can use this function: date ( string $format [, int $timestamp ] ). So you can do this:



                          echo date( "d/m/Y", strtotime ( $your_date ) );



                          You can find full description here: http://php.net/manual/en/function.date.php







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 19 '10 at 20:06









                          D.MartinD.Martin

                          861




                          861























                              1














                              After getting it from the DB, use $time = strtotime($value) to convert it to a timestamp in PHP. Then use date("d/m/Y", $time) to get it in that format.






                              share|improve this answer




























                                1














                                After getting it from the DB, use $time = strtotime($value) to convert it to a timestamp in PHP. Then use date("d/m/Y", $time) to get it in that format.






                                share|improve this answer


























                                  1












                                  1








                                  1







                                  After getting it from the DB, use $time = strtotime($value) to convert it to a timestamp in PHP. Then use date("d/m/Y", $time) to get it in that format.






                                  share|improve this answer













                                  After getting it from the DB, use $time = strtotime($value) to convert it to a timestamp in PHP. Then use date("d/m/Y", $time) to get it in that format.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Mar 19 '10 at 19:57









                                  St. John JohnsonSt. John Johnson

                                  5,47373054




                                  5,47373054























                                      1














                                      If you used some Framework like Zend, it would be very easy because you have plenty of classes to handle databases and date formatting. Then you would always see the output as the Brazilian date format. Just like Delphi TDateField uses Windows date format in the current computer, Zend will look up in your own configuration.






                                      share|improve this answer




























                                        1














                                        If you used some Framework like Zend, it would be very easy because you have plenty of classes to handle databases and date formatting. Then you would always see the output as the Brazilian date format. Just like Delphi TDateField uses Windows date format in the current computer, Zend will look up in your own configuration.






                                        share|improve this answer


























                                          1












                                          1








                                          1







                                          If you used some Framework like Zend, it would be very easy because you have plenty of classes to handle databases and date formatting. Then you would always see the output as the Brazilian date format. Just like Delphi TDateField uses Windows date format in the current computer, Zend will look up in your own configuration.






                                          share|improve this answer













                                          If you used some Framework like Zend, it would be very easy because you have plenty of classes to handle databases and date formatting. Then you would always see the output as the Brazilian date format. Just like Delphi TDateField uses Windows date format in the current computer, Zend will look up in your own configuration.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Mar 1 '13 at 12:17









                                          Please_Dont_Bully_Me_SO_LordsPlease_Dont_Bully_Me_SO_Lords

                                          3,7411259113




                                          3,7411259113























                                              1














                                              i'm using this script and put it on upper line.



                                              $(function(){
                                              var pickerOpts = {
                                              dateFormat: "yy-mm-dd"
                                              };
                                              $("#datepicker").datepicker(pickerOpts);
                                              });


                                              and this one in your form.



                                              <input id=**"datepicker" type="date"** name="Start"  size="9" value="<?php  

                                              echo $Start;

                                              ?>" />


                                              It will appear as d/m/y on your page but in your database y/m/d.






                                              share|improve this answer






























                                                1














                                                i'm using this script and put it on upper line.



                                                $(function(){
                                                var pickerOpts = {
                                                dateFormat: "yy-mm-dd"
                                                };
                                                $("#datepicker").datepicker(pickerOpts);
                                                });


                                                and this one in your form.



                                                <input id=**"datepicker" type="date"** name="Start"  size="9" value="<?php  

                                                echo $Start;

                                                ?>" />


                                                It will appear as d/m/y on your page but in your database y/m/d.






                                                share|improve this answer




























                                                  1












                                                  1








                                                  1







                                                  i'm using this script and put it on upper line.



                                                  $(function(){
                                                  var pickerOpts = {
                                                  dateFormat: "yy-mm-dd"
                                                  };
                                                  $("#datepicker").datepicker(pickerOpts);
                                                  });


                                                  and this one in your form.



                                                  <input id=**"datepicker" type="date"** name="Start"  size="9" value="<?php  

                                                  echo $Start;

                                                  ?>" />


                                                  It will appear as d/m/y on your page but in your database y/m/d.






                                                  share|improve this answer















                                                  i'm using this script and put it on upper line.



                                                  $(function(){
                                                  var pickerOpts = {
                                                  dateFormat: "yy-mm-dd"
                                                  };
                                                  $("#datepicker").datepicker(pickerOpts);
                                                  });


                                                  and this one in your form.



                                                  <input id=**"datepicker" type="date"** name="Start"  size="9" value="<?php  

                                                  echo $Start;

                                                  ?>" />


                                                  It will appear as d/m/y on your page but in your database y/m/d.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited Apr 5 '16 at 1:57









                                                  Chaithanya

                                                  95621527




                                                  95621527










                                                  answered Apr 5 '16 at 1:12









                                                  Nurfaezah HanisNurfaezah Hanis

                                                  111




                                                  111























                                                      0














                                                      This mysql function will return the correct format in the result



                                                      SELECT DATE_FORMAT(date_field, "%M %d %Y");





                                                      share|improve this answer




























                                                        0














                                                        This mysql function will return the correct format in the result



                                                        SELECT DATE_FORMAT(date_field, "%M %d %Y");





                                                        share|improve this answer


























                                                          0












                                                          0








                                                          0







                                                          This mysql function will return the correct format in the result



                                                          SELECT DATE_FORMAT(date_field, "%M %d %Y");





                                                          share|improve this answer













                                                          This mysql function will return the correct format in the result



                                                          SELECT DATE_FORMAT(date_field, "%M %d %Y");






                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Mar 21 '18 at 14:24









                                                          NandhiniNandhini

                                                          447




                                                          447























                                                              0














                                                              $dtShowDate = $_POST['dtShowDate'];
                                                              $date =explode('-', $dtShowDate)0;
                                                              $showdate = $date[2]."-".$date[0]."-".$date[1];



                                                              Set Date as per your need






                                                              share|improve this answer






























                                                                0














                                                                $dtShowDate = $_POST['dtShowDate'];
                                                                $date =explode('-', $dtShowDate)0;
                                                                $showdate = $date[2]."-".$date[0]."-".$date[1];



                                                                Set Date as per your need






                                                                share|improve this answer




























                                                                  0












                                                                  0








                                                                  0







                                                                  $dtShowDate = $_POST['dtShowDate'];
                                                                  $date =explode('-', $dtShowDate)0;
                                                                  $showdate = $date[2]."-".$date[0]."-".$date[1];



                                                                  Set Date as per your need






                                                                  share|improve this answer















                                                                  $dtShowDate = $_POST['dtShowDate'];
                                                                  $date =explode('-', $dtShowDate)0;
                                                                  $showdate = $date[2]."-".$date[0]."-".$date[1];



                                                                  Set Date as per your need







                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited Jan 3 at 7:29









                                                                  Akash Dubey

                                                                  610827




                                                                  610827










                                                                  answered Jan 3 at 7:03









                                                                  Keval MehtaKeval Mehta

                                                                  11




                                                                  11






























                                                                      draft saved

                                                                      draft discarded




















































                                                                      Thanks for contributing an answer to Stack Overflow!


                                                                      • Please be sure to answer the question. Provide details and share your research!

                                                                      But avoid



                                                                      • Asking for help, clarification, or responding to other answers.

                                                                      • Making statements based on opinion; back them up with references or personal experience.


                                                                      To learn more, see our tips on writing great answers.




                                                                      draft saved


                                                                      draft discarded














                                                                      StackExchange.ready(
                                                                      function () {
                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f2480186%2fchange-date-format-in-db-or-output-to-dd-mm-yyyy-php-mysql%23new-answer', 'question_page');
                                                                      }
                                                                      );

                                                                      Post as a guest















                                                                      Required, but never shown





















































                                                                      Required, but never shown














                                                                      Required, but never shown












                                                                      Required, but never shown







                                                                      Required, but never shown

































                                                                      Required, but never shown














                                                                      Required, but never shown












                                                                      Required, but never shown







                                                                      Required, but never shown







                                                                      Popular posts from this blog

                                                                      Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                                                                      Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

                                                                      A Topological Invariant for $pi_3(U(n))$