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 8438219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:38:59+00:00 2026-06-10T07:38:59+00:00

I have a form with a jQuery datepicker. I have set the date format

  • 0

I have a form with a jQuery datepicker. I have set the date format to the European way: dd-mm-yy in order to make it look nice for the user. However this date value eventually needs to be formatted back in PHP to yy-mm-dd so that in can be stored in my mysql DATE field. Here is my code:

Jquery:

   $("document").ready(function(){

    $(function() {
    $( ".datepicker" ).datepicker({
        monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
                     'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
        dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'],
        dateFormat:'dd-mm-yy',
        });
});
  • 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-06-10T07:39:01+00:00Added an answer on June 10, 2026 at 7:39 am

    You have three options (in some vague order of preference):

    1. Use MySQL’s STR_TO_DATE() function to convert the string:

      INSERT INTO ... VALUES (STR_TO_DATE(:date, '%d/%m/%Y'))
      
    2. Convert the string received from jQuery into a PHP DateTime object:

      $dt = DateTime::createFromFormat('d/m/Y', $_POST['date']);
      

      and then either:

      • obtain a suitable formatted string:

        $date = $dt->format('Y-m-d');
        
      • obtain the UNIX timestamp:

        $timestamp = $dt->getTimestamp();
        

        which is then passed directly to MySQL’s FROM_UNIXTIME() function:

        INSERT INTO ... VALUES (FROM_UNIXTIME(:timestamp))
        
    3. Manually manipulate the string into a valid literal:

      $parts = explode('-', $_POST['date']);
      $date  = "$parts[2]-$parts[1]-$parts[0]";
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a date field (i'm using the jquery ui datepicker) in a form
I have a form with an date field with a jquery datepicker attached to
I have used Jquery UI DatePicker for the option in my form to select
I have a form which includes a JQUERY datepicker attatched to an <input> on
I have jQuery Datepicker inside my form. My problem is after I have clicked
I am using the jQuery datepicker to request date input from the user. I
I'm trying to set a range for a jquery datepicker that I have on
I am using jQuery mobile 1.1.0. I have a form where the user can
I'm using the datepicker form jQuery-ui-1.8.16. I have the following code: Site.Calendar = function()
I have a form what jQuery sents for me using Ajax to php. For

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.