Solved

Format date

Posted on 2014-02-06
5
377 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 33

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How Close unsubmited attempts 10 47
Make check boxes work 8 47
How do I post more than 1 item to php backend 24 32
Building JSON/JQuery Results Display 11 28
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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…

730 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