?
Solved

Format YYYY-MM-DD Datepicker from jqueryui

Posted on 2009-04-04
3
Medium Priority
?
494 Views
Last Modified: 2013-11-23
I am working with http://jqueryui.com/demos/datepicker/ to place in my html a datepicker so the user just click & select.

It works fine, but I need to have the text/input field return the format YYYY-MM-DD, its returning MM-DD-YYYY.

I have reviewed thier section on date format (http://jqueryui.com/demos/datepicker/#date-formats), but it seems that I need to have the date format window present in order to work.

How can I format the line to work strictly with: YYYY-MM-DD

Heres my code:

      $(function() {
        $("#From").datepicker();
        $("#format").change(function() { $('#From').datepicker('option', {dateFormat: $(this).val()}); });
            $("#To").datepicker();
        $("#format").change(function() { $('#To').datepicker('option', {dateFormat: $(this).val()}); });
      });
0
Comment
Question by:rayluvs
[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
3 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 24067899
Without seeing all the code, it's hard to give you an exact answer and a code sample, but I can tell you the "best practices" way of dealing with date format conversions.

Use the functions strtotime() and date() to get this done.
http://us2.php.net/manual/en/function.strtotime.php
http://us2.php.net/manual/en/function.date.php

An example:
$iso_date = date('Y-m-d', strtotime('March 31, 2007'));

HTH, ~Ray
0
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 2000 total points
ID: 24067938
Have you tried this:

$("#From").datepicker({ dateFormat: 'yy-mm-dd' });
0
 

Author Comment

by:rayluvs
ID: 24068198
Thanx for the link Ray, I already have that...I'm looking for something for a user to click at, and the jqueryui works excellente!

cxr your solutions worked!  Thanx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This article discusses how to create an extensible mechanism for linked drop downs.
This video teaches viewers about errors in exception handling.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

777 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