I want to know how I get a date from an input of type date in the format dd-(Month in English)-yy, an example would be:
function handleSubmit(event) {
event.preventDefault();
let fechaAFormatear = event.target.datePicker.value
// Algoritmo para formatear la fecha
//...
//...
//...
let fechaFormateada = fechaAFormatear
console.log(fechaFormateada) // => algun tipo de fecha con el formato dd-(Nombre del mes en ingles)-yy, ejemplo: 29-Jun-21
}
<form onSubmit="handleSubmit()">
<input id="datePicker" type="date" />
<input type="submit" />
</form>
This is just an example of how I want to achieve it, if you have any Regexp or if you can use any kind of help I would appreciate it, the thing is that I am new to JS and I am learning.
In the handleSubmit code you use a reserved word as the name of the parameter, that is not correct, you can even put ev on it (or nothing because it is not essential).
Once you have read the date, you build a Date object and pass it to local format, but you want a mixture: Spanish format (day/month/year) but names in English ('en-EN') and separated by /
Well, nothing: You read the day, the year and the month in English format and then join them. The event script is left to you
True, you could also get the string in English and then reorder using regular expressions, but if you're just starting out this solution is clear and easy to understand.