?
Solved

Format date

Posted on 2014-02-06
5
Medium Priority
?
390 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

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 2000 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

Stack Overflow Podcast - Developer Story

Welcome to the Stack Overflow podcast recorded Thursday July 20 at Stack Overflow Headquearters in NYC. Your hosts today are podcast regulars Jay Hanlon, David Fullerton, and Ilana Yitzhaki, plus the quite irregular Matt Sherman (Stack Overflow Engineering Manager extraordinaire)

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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…
Suggested Courses

765 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