MySQL Date Input

Posted on 2011-10-07
Last Modified: 2012-05-12
I'm building a PHP database front end with a MySQL backend and it's great, MySQL is perfect. Well almost. The way you enter dates here is not intuitive. I want to create some kind of mask that will allow me to enter a date as MM-DD-YYYY or MM/DD/YYYY and then have it resolve to YYYY-MM-DD. Any help is appreciated.
Question by:brendan-amex
    LVL 13

    Expert Comment

    by:Hugh McCurdy
    You can start by using strtotime()

    Then you can use date() to format the date however you want.
    LVL 8

    Accepted Solution

    You can do it with jQuery UI datepicker:

    It has very well documentation.


    Author Comment

    fishboy - thank you. that's a great option. I have it on my site but I want to be able to remove the drop down for format options and have the default be the second option yy-mm-dd to match MySQL, do you know how I can change the default so I can remove the dropdown? If I remove the dropdown now, it reverts back to the mm/dd/yy default.

    Author Comment

    Ignore that. I figured it out. Thank you! A+
    LVL 8

    Expert Comment

    by:Ahmed Merghani
    You are welcome

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to count occurrences of each item in an array.

    732 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

    20 Experts available now in Live!

    Get 1:1 Help Now