close ad
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

How to format DatePicker date to dd/mm/yyyy so that it displays correctly in the form field and is validated correctly?

Thread began 12/09/2013 8:56 am by FPhu61701534 | Last modified 12/10/2013 8:50 am by FPhu61701534 | 12476 views | 6 replies

Jason ByrnesWebAssist

so the issue now not that it is not passing validation, but what is being stored in the database, right?

in the update behavior, the code has to reformat the date to be compatible with MySQL. it uses the date and strtotime function refomat the date to yyyy-mm-dd H:i:s format:

date("Y-m-d H:i:s", strtotime($_POST["session_date_start"]))

the problem with this is that the strtotime function uses the separator to determine if the data uses the US Format or the UK format. From the php web site:

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.  

When the separator uses a slash, strtotime assumes the US m/d/y format, but you are passing it as d/m/y

one of 2 way to fix it:
1) Use the dash separator instead

2) add code at line one of your page to convert the slash to a dash
<?php if(isset($_POST["session_date_start"])) $_POST["session_date_start"] = str_replace("/","-",$_POST["session_date_start"]); ?>

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





Ease of use


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...