I have the following code to generate a WhatsApp API url according to the information from the form. The problem is: the date, when the javascript calls it, changes from DD/MM/AAAA to AAAA/MM/DD.
I wanted the output to be DD/MM/AAA, I couldn't find any help in google, can someone help?
P.S.: there are two buttons, one to send the form via e-mail, and another via whatsapp (the e-mail button is not set yet).
<!-- FORM HTML -->
<form id="form_orcamento" class="grid-8 form" autocomplete="off">
<label for="nome"></label>
<input type="text" id="name" placeholder="nome" required>
<label for="email"></label>
<input type="email" id="email" placeholder="e-mail" required>
<label for="telefone"></label>
<input type="tel" id="phone" placeholder="telefone" required>
<p class="label_de">data de entrada</p>
<p class="label_ate">data de Saída</p><br>
<label for="from"></label>
<input placeholder="Entrada" type="date" id="from" name="from" class="de entrada" min='1899-01-01' max='2050-13-13'>
<label for="to"></label><input placeholder="Saída" type="date" id="to" name="to" class="de"></div>
<div class="grid-8">
<label for="msg"></label>
<textarea class="msg" id="service" placeholder="Mensagem" required></textarea>
<div class="button">
<button type="submit" class="btn">Enviar por E-mail</button>
<input type="submit" name="submit" class="btn" value="Whatsapp" onclick="gotowhatsapp()"/>
</form>
</div>
</div>
//JAVASCRIPT
function gotowhatsapp() {
var name = document.getElementById("name").value;
var phone = document.getElementById("phone").value;
var email = document.getElementById("email").value;
var from = document.getElementById("from").value;
var to = document.getElementById("to").value;
var service = document.getElementById("service").value;
var url = "https://wa.me/1999999999?text="
+ "Name: " + name + "%0a" + "%0a"
+ "Telefone: " + phone + "%0a" + "%0a"
+ "E-mail: " + email + "%0a" + "%0a"
+ "Entrada: " + from + "%0a" + "%0a"
+ "Saída: " + to + "%0a" + "%0a"
+ "Mensagem: " + "%0a" + service;
window.open(url, '_blank').focus();
}```