Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Format YYYY-MM-DD Datepicker from jqueryui

Posted on 2009-04-04
3
Medium Priority
?
496 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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

597 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