insert date in mysql database "ex. day/month/year"

Asked

Viewed 114 times

1

I’m a beginner, I use bd mysql and php, I’m not sure about my database.

use the following input:

<input type="text" placeholder="Data de início" class="btntarefa" name="dataInicio" id="dataInicio" data-uk-datepicker="{format:'DD.MM.YYYY'}">

after running my Insert:

$comandoSql="INSERT INTO tbTarefa 
                         (nomeTarefa, dataInicio , dataTermino, anexos, observacao, status, codObra)    
                    VALUES 
                         ('".$tarefa."', '".$data1."', '".$data2."', '".$anexo."', '".$observacao."', '".$status."', '".$idObra."')";

the result is:

inserir a descrição da imagem aqui

My question is how I can insert in the day/month/year format

I researched and found this:

SET evn_dtevent = STR_TO_DATE( "31/05/2014", "%m/%d/%Y" )

However I tried to adapt it in my Internet and presented syntax error, could help me regarding this or other way that can solve my problem, from now Thank you

  • have tried that > data-uk-datepicker="{format:'YYYY.DD.MM'}" a lot of times it works!

  • 2

    Mysql Database is configured ANO/MES/DIA is your default date storage. When you receive the date, you must convert to this format and write to the database as already said.

  • 1

    http://answall.com/questions/26968/inserir-data-no-mysql-via-php

  • Here are several ways to convert: http://answall.com/questions/21774/comort-datas-no-php-independente-format

  • 1

    @Gokussjgod Thank you, after checking the link http://answall.com/questions/26968/inserir-data-no-mysql-via-php, I found this echo date(’d-m-Y', strtotime($venc_garantia)); , and so I decided to store it in a variable and then display-la segue: $dInicio = $line['dataInicio']; $dInicio1 = date(’d-m-Y', strtotime($dInicio));

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.