Where will this date come from? Will it be a form where the user will enter the date? If so, then you don’t even need to use jQuery, just enter a field of the type date
in the form, as shown below:
<form action="pagina.php" method="POST">
<input type="date" name="data" id="data">
</form>
Obs.: Although in the field the date appears in DD/MM/YYYY format, when you receive the value entered in the field it will come in YYYY-MM-DD format.
From there, it will be enough to separate the date values with the function of the explode
of PHP:
$data = $_POST['data'];
$partes = explode("-", $data);
// ANO Mês DIA
// $partes[0] $partes[1] $partes[2]
$day = $partes[2];
$month = $partes[1];
$year = $partes[0];
Edit:
How do you get that date? If it comes from the bank, after storing it in a variable, you can pass it to the script and then dismember the date the way you need it:
var data = "<?php echo $data; ?>";
var array = data.split("-");
var day = array[2];
var month = array[1];
var year = array[0];
Where does the date come from? See if the comment above helps you - if it doesn’t help, please include your code in the question.
– Daniel
Ok, I have already put that the date comes predefined from another field and returns this string as text. 2017-06-30 and need to divide and play in another field year: , Month:, day: ,
– Rafael Meirim
Please mark the answer as accepted, if it solved your problem. And take the tour!
– Daniel