close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Date picker UK date to database

Thread began 5/09/2014 11:47 am by Daryl | Last modified 5/09/2014 12:31 pm by Jason Byrnes | 422 views | 3 replies |

DarylBeta Tester

Date picker UK date to database

I have adjusted the code in the date picker to display the date in the date picker as a UK Date

How do I change this code to change the date to a MYSQL friendly date format to insert it into the database?

<?php echo ((isset($_POST["albumDate"]) && $_POST["albumDate"]!="" )?date("Y-m-d H:i:s", strtotime($_POST["albumDate"])):""); ?>

This code unfortunately posts the date from d/m/Y into Y-d-m rather than Y-m-d

Sign in to reply to this post

Jason ByrnesWebAssist

I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post

DarylBeta Tester

Thanks Jason

Sign in to reply to this post

Jason ByrnesWebAssist

the strtotime() function uses the date separator as an indictation of the date format.

if the slash (/) separator is used, strtotime() assumes a US formated date:
m/d/Y

if the dot (.) seperator is used, strtotime() assumes a UK formated date:
d.m.Y

You datepicker was using the UK format with a slash as the separator which caused strtotime to be unable to recognize a valid date.

to fix your problem, I used str_replace to replace the / with . in the date at line 1:

<?php
if(isset($_POST['albumDate'])) $_POST['albumDate'] = str_replace("/",".",$_POST['albumDate']);
?>



this passed the correct separator so the strtotime() function could read the date properly

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...