Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7634955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:18:58+00:00 2026-05-31T07:18:58+00:00

I have a date picker that generates a date like 6/30/2012 in a form

  • 0

I have a date picker that generates a date like 6/30/2012 in a form field.

I need to convert this date to 2012-06-30 for mysql. I can get it close with the following.

var datePart=document.getElementById('formdate').value.split(/[^0-9]+/);

and then use to generate the date.

datePart2[2] + "-" + datePart2[1] + "-" + datePart2[0]

The problem is it gived me the date 2012-6-30 instead of 2012-06-30.

Is there an easier way to do this? Or a way to use my current method and ad a zero to the front of a digit if it is a single digit?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:18:59+00:00Added an answer on May 31, 2026 at 7:18 am

    The Open Source date.js ( http://www.datejs.com/ )provides a really extensive framework for JavaScript dates, IMHO superior to the jQuery plug-in. It may be more than you need for this requirement, but I think it is a welcome addition to any JavaScript programmers’s arsenal.

    To format your example:

    var mySqlDate = Date.parse('6/30/2012').toString('yyyy-MM-dd');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a date picker. After choosing a time from this I would like
I have a Basic Date picker and i would like to get its value
I have this C# webform that has has a date picker box. If the
I have a date picker library written for MooTools that I want to port
I need to limit the jquery ui date picker to only have future Tuesdays
I am trying to find a date picker that can show dates to select
I have a input field and on clicking that I will show a date
I have a date picker that allows a user to select a date, by
I have an implementation of the J-Query UI date picker that i am using
I have a jquery ui framework that is constructing the Date Picker elements. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.