Is it possible convert a date value from datepicker into words ?, I know there have been several similar questions here, but I want to do a different approach.
Now I'm trying to use alert to find out the value of the variable before the format changed to words, then there is error message about the index number in the array. it said :uncaught SyntaxError : unexpected Number which is this line bulan 1 januari
is there any advice, to give value to key in the array ?
$( function() {
$( "#pickyDate" ).datepicker({format: "dd/mm/yyyy"});
local = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu' ];
bulan = [1=>'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni','Juli','Agustus','September','Oktober','November','Desember' ];
$('#getdate').datepicker()
.on("change", function () {
var today = new Date($('#getdate').datepicker('getDate'));
var tanggal = today.getDate();
var no_hari = today.getDay();
var no_bulan = today.getMonth()+1;
var tahun = today.getFullYear();
//alert(local[today.getDay()]);
alert(tahun);
//$('#wordsdate').val(local[today.getDay()]);
});
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<div class="form-group">
<input type="text" class="form-control" placeholder="choose date" id="getdate" />
</div>
<div class="form-group">
<input type="hidden" class="form-control" placeholder="datepicker date" id="datenum" disabled/>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="wordsdate" id="wordsdate" disabled/>
</div>
example :
let say we choose a date : 05/06/2014
then result on textfield : the fifth of June Two thousand and fourteen