Solved

Format YYYY-MM-DD Datepicker from jqueryui

Posted on 2009-04-04
3
489 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 109

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

839 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