This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Formatar o dia de hoje: formatDateBr(new Date()); | |
* Formatar um dia em especifico: formatDateBr(new Date('2018-08-20')); | |
* Formatar um timestamp especifico: formatDateBr(new Date(1534778906831)); | |
*/ | |
function formatDateBr(data) { | |
const dia = data.getDate() < 10 ? '0'+data.getDate() : data.getDate(); | |
const mes = (data.getMonth()+1) < 10 ? '0'+(data.getMonth()+1) : (data.getMonth()+1); | |
const ano = data.getFullYear(); | |
return dia+'/'+mes+'/'+ano; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converter o dia de hoje: formatDate(new Date()); | |
* Converter um dia em especifico: formatDate(new Date('2018-08-20')); | |
* Converter um timestamp especifico: formatDate(new Date(1534778906831)); | |
*/ | |
function formatDate(data) { | |
const dia = data.getDate() < 10 ? '0'+data.getDate() : data.getDate(); | |
const mes = (data.getMonth()+1) < 10 ? '0'+(data.getMonth()+1) : (data.getMonth()+1); | |
const ano = data.getFullYear(); | |
return ano+'-'+mes+'-'+dia; |