Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);
like image 959
TheDarkCode Avatar asked Apr 15 '14 18:04

TheDarkCode


1 Answers

function convertDigitIn(str){
   return str.split('/').reverse().join('/');
}
like image 130
Denys Séguret Avatar answered Oct 14 '22 15:10

Denys Séguret