3
How to convert a Date
for the full date?
I would like to show today’s date in the following format:
Thursday, 20 July 2017
The example code you would like to complete to get the above result in a label
is exemplified below, needing to change the region of the comment to the logic of obtaining the date.
$(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>
<script src="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>
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
– MagicHat
Maybe this Link will help "https://answall.com/questions/6526/comorformatr-data-no-javascript". There is also a date library that was mentioned here: "http://momentjs.com/"
– Leonardo Paim
use : https://momentjs.com/ help?
– Rafael Salomão
Is that something you need? https://jsfiddle.net/trgva8L1/
– Woss
@Andersoncarloswoss exactly
– Sorack