Solved

Format date

Posted on 2014-02-06
5
365 Views
Last Modified: 2014-02-06
Hi,

var TodayDate = new Date();
var SetDate =(TodayDate .getMonth()+1) + '/' + TodayDate .getDate() + '/' +
        TodayDate .getFullYear();
$("#GetDateFrom").val(SetDate );

I need to format the value in the GetDateFrom field to mm dd yyyy.

Thanks,
0
Comment
Question by:lulu50
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:David Kroll
ID: 39838908
0
 

Author Comment

by:lulu50
ID: 39839000
dkrollCTN,

I want it to display the date like this 02/06/2014

but now it display the date like this 2/6/2014
0
 
LVL 11

Expert Comment

by:David Kroll
ID: 39839021
var TodayDate = new Date();
var SetDate =(TodayDate .getMonth().ToString()+1) + '/' + TodayDate .getDate().ToString() + '/' +
        TodayDate .getFullYear();
$("#GetDateFrom").val(SetDate );
0
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
ID: 39839307
try this:

var TodayDate = new Date();

var theMonth = TodayDate .getMonth()+1;
if( theMonth < 10 )   theMonth = '0' + theMonth ;

var theDay = TodayDate .getDate();
if( theDay < 10 )        theDay = '0' + theDay;


var SetDate =theMonth + '/' + theDay + '/' + TodayDate .getFullYear();
$("#GetDateFrom").val(SetDate );

Open in new window

0
 

Author Closing Comment

by:lulu50
ID: 39839328
THANK YOU!!!!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now