Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

This code will help u

JavaScript
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);
  }


Happy coding ... :)
Seshu
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900