'How can i get a date with yyyy_mm_dd format from a datepicker?
i have 2 datepickers, both of them have the same structuture. The only difference is their name. One has id="fecha_1_1" and the other one id="fecha_1_2"
<div class="col-sm-3">
<p>Desde</p>
<div class="form-group">
<div class="form-line">
<input id="fecha_1_2" type="text" class="datepicker form-control" placeholder="Seleccione una fecha de inicio" />
</div>
</div>
</div>
and i detect if one of them changes with this sentence:
$('#fecha_1_2, #fecha_1_1').bootstrapMaterialDatePicker().on('dateSelected', function (e, date)
the problem is that i need to access to the date of the one that didn´t triggered the ajax sentence, and with $(fecha_x_x).val() i get a date with the format day, dd mm yyyy and i need it with yyyy_mm_dd format
Solution 1:[1]
If you want to make it in pure Javascript you can use toISOString() that would give you something like this: 2021-07-02T13:06:53.422Z (YYYY-MM-DD HH:mm:ss sss) , or you try it with moment().format('YYYY-MM-DD');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Autogrammgeber96 |
