Contact Form - Sending date 0000-00-00

Asked

Viewed 63 times

1

Good morning, I made a contact form and put one but when I put the date right example: 31/08/2017, I click to send the date comes as: 2017/08/31, I would like to leave as standard Brazil.

My input:

<input type="text" onfocus="(this.type='date')" name="datadenascimento" id="datadenascimento" class="gui-input" placeholder="Data de Nascimento">

The string that makes the upload:

$datadenascimento = strip_tags(trim($_POST["datadenascimento"]));
  • 1

    Just a tip. Most recommended is to use Trim(strip_tags($_POST["dated"]));

1 answer

1

Use the "date_formate" of php itself!

$data = $_POST['datadenascimento'];
$data_cria = new DateTime($data);

$data_formata = $data_cria->format('d/m/Y');

Read more here

  • 1

    You are giving the following error: Warning: date_format() expects Parameter 1 to be Datetimeinterface

  • 1

    Sorry. My mistake. I already packed! Check now!

  • I put but still keep coming as: "Date of Birth: 2017-11-30"

  • Can you show me the final code? Why is it working: http://cartola.ml/teste.php

Browser other questions tagged

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