将javascript日期从yyyy / mm / dd反转为dd / mm / yyyy [英] reverse date javascript from yyyy/mm/dd to dd/mm/yyyy

查看:53
本文介绍了将javascript日期从yyyy / mm / dd反转为dd / mm / yyyy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个asp项目,日期显示为yyyy / mm / dd,但是当用户按下表格的编辑按钮时,我需要将日期格式替换为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

这个asp代码记住我需要用户在表中将日期显示为yyyy / mm / dd,但是当他按下按钮时,我需要将日期反转为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>

,这是date元素的javascript代码:

and this the javascript code for the date element:

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


推荐答案

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

这篇关于将javascript日期从yyyy / mm / dd反转为dd / mm / yyyy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆