[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • Last Modified:

MySQL Date Input

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.
0
brendan-amex
Asked:
brendan-amex
  • 2
  • 2
1 Solution
 
Hugh McCurdyCommented:
You can start by using strtotime()  

http://www.w3schools.com/php/php_ref_date.asp
http://www.w3schools.com/php/func_date_strtotime.asp

Then you can use date() to format the date however you want.
http://www.w3schools.com/php/func_date_date.asp
0
 
Ahmed MerghaniCommented:
You can do it with jQuery UI datepicker:

http://jqueryui.com/demos/datepicker/

It has very well documentation.

0
 
brendan-amexAuthor Commented:
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.
0
 
brendan-amexAuthor Commented:
Ignore that. I figured it out. Thank you! A+
0
 
Ahmed MerghaniCommented:
You are welcome
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now