Solved

Format YYYY-MM-DD Datepicker from jqueryui

Posted on 2009-04-04
3
482 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
3 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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 500 total points
Comment Utility
Have you tried this:

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

Author Comment

by:rayluvs
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to validate 2 forms at once 8 24
whm high memory usage in processes 7 33
Button Click 11 22
maven project error 5 16
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now