I have a jquery calendar that sets the input value to MM/DD/YYYY
How would I convert it so that my database column (date) can accept it correctly?
EDIT
Gordon was right - his link pointed me to this answer
$mysql_date = date('Y-m-d H:i:s', strtotime($user_date));
First, pick the cells that contain dates, then right-click and select Format Cells. Select Custom in the Number Tab, then type 'dd-mmm-yyyy' in the Type text box, then click okay. It will format the dates you specify.
Select the cells you want to format. Press CTRL+1. In the Format Cells box, click the Number tab. In the Category list, click Date, and then choose a date format you want in Type.
Two extract the value for Month, first note that we have to cut the first four digits off so that yyyymmdd becomes mmdd. Then, dividing mmdd by 100 yields mm. This is done with MOD(Number,10000)/100, where MOD(Number,10000) retrieves mmdd and this result is divided by 100 yielding Month.
Go to Format Cells > Custom Enter mm/dd/yyyy in the available space. Or you can use : Select a blank cell next to your date, for instance.
$date = "07/12/2010"; $your_date = date("Y-m-d", strtotime($date));
I hope my answer is useful :)
You want to do this in PHP, right?
Use Explode
$christmas = "12/25/2010"; $parts = explode('/',$christmas); $yyyy_mm_dd = $parts[2] . '-' . $parts[0] . '-' . $parts[1]
Use strptime
to parse it to a timestamp and then strftime
to format it the way you want it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With