How do I convert a Date
to date in full?
I would like to show today's date in the following format:
Thursday, July 20, 2017
The example code that you would like to complete to get the above result in a label
is exemplified below, needing to change the comment region to the date retrieval logic.
$(function() {
$('#datepicker').datepicker({dateFormat: 'dd/mm/yy'});
$('#btnFormatar').click(formatar);
});
function formatar() {
var data = $('#datepicker').datepicker('getDate');
var extenso;
// Lógica para formatar a data
extenso = '*DIA DA SEMANA*, *DIA DO MÊS* de *MÊS* de *ANO*';
console.log(data);
$('#lblDataExtenso').html(extenso);
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Data: <input type="text" id="datepicker"></p>
<p><button id="btnFormatar">Formatar</button>
<p><label id="lblDataExtenso">???</label></p>