reverse date javascript from yyyy/mm/dd to dd/mm/yyyy

丶灬走出姿态 提交于 2019-12-04 03:17:08

问题


I making an asp project and the date is displayed as yyyy/mm/dd but when the user press on the edit button for the form i need to replace the date format with dd/mm/yyyy

this the asp code remember i need the user to show the date as yyyy/mm/dd in the table but when he pressing on a button i need the date to be reversed to dd/mm/yyyy

 <td class="hidden-phone">@EnnotaBAL.ArabicEncoding.GetArabicNumbers(transaction.PostDate.ToString("yyyy/MM/dd"))</td>

and this the javascript code for the date element:

// Transaction Date
var TransDate = oCells.item(4).innerHTML;
document.getElementById('Date').value = convertDigitIn(TransDate);

回答1:


function convertDigitIn(str){
   return str.split('/').reverse().join('/');
}


来源:https://stackoverflow.com/questions/23091333/reverse-date-javascript-from-yyyy-mm-dd-to-dd-mm-yyyy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!