jQuery中的日期格式 [英] Date Format in Jquery

查看:77
本文介绍了jQuery中的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的jquery视图中有以下代码,显示数据库中的日期
交易日期:@ Html.DisplayFor(modelItem => item.transaction_date)
以上返回:交易日期:01/01/1900 00:00:00

我想格式化日期,以便可以以以下格式显示:
(dd-MM-yyyy),即01-01-1900

任何帮助将不胜感激

Hi,

I have the following code in my jquery view displaying the date from the database
Transaction Date:@Html.DisplayFor(modelItem => item.transaction_date)
The above returns: Transaction Date:01/01/1900 00:00:00

I would like to format the date so that in can display in the following format:
(dd-MM-yyyy) i.e 01-01-1900

Any help will be appreciated

推荐答案

此代码将为您提供帮助

This code will help u

function todate(){
      var d=new Date();
      var dat=d.getDate();
      var dd = (dat < 10) ? '0' + dat : dat;
      var month=d.getMonth()+1;
      var mm = (month < 10) ? '0' + month : month;
      var yyyy = (new Date().getFullYear()).toString();
      var yy = yyyy.substring(yyyy.length, 2)
      var todayDate = mm+"-"+dd+"-"+yy;
      tdate=todayDate;
      curdt = new Date(tdate);
  }



快乐的编码... :)
Seshu



Happy coding ... :)
Seshu


这篇关于jQuery中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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