close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Datepicker - UK date format

Thread began 3/18/2013 9:30 am by iainmacdonald331081 | Last modified 3/18/2013 3:30 pm by iainmacdonald331081 | 1418 views | 4 replies |

iainmacdonald331081

Datepicker - UK date format

Sorry - I know you get asked about this a lot.

I've done a search, but as far as I can tell there may be more than one variation of the datepicker code, and I haven't found how to change it.

I've found the format mm/dd/yy and changed that to dd/mm/yy, which correctly changes how it appears in the input box once selected.

But I can't see where the mm/dd/yy format is being converted to yyyy/mm/dd for SQL.

So although when it is mm/dd/yy it is getting converted correctly to yy/mm/dd, when I change to dd/mm/yy it ends up as the default 1 January 1970.

I've attached the page with the datepicker - if you could point me in the right direction to have it as dd/mm/yy in the imput box, and still end up correct in the DB that would be great.

Thank you.

Sign in to reply to this post

Jason ByrnesWebAssist

line 86 of your page performs the conversion to yyyy-mm-dd format using the date() and strtotime() functions.

php:
."" . $WA_AB_Split . "".((isset($_POST["EventDate"]) && $_POST["EventDate"]!="" )?date("Y-m-d H:i:s", strtotime($_POST["EventDate"])):"")




the problem is in the way strtotime() works. strtotime looks at the separator to determine the date format being used.

it sees the "/" separator as a US date and the "-" separator as a UK date.

to work around this problem, change the following code:

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



to:

php:
date("Y-m-d H:i:s", strtotime(str_replace("/","-",$_POST["EventDate"])))
Sign in to reply to this post

iainmacdonald331081

Thanks Jason - I can't see anything obvious, but its giving an error on line 91:

."";

which is stopping the page from loading.

Can you spot a typo on the revised page attached?

Sign in to reply to this post

Jason ByrnesWebAssist

the code at lines 83 - 91 should not be on separate lines, that code should all be one line.

Sign in to reply to this post

iainmacdonald331081

Thanks Jason - I do that sometimes if I need to manually add an extra field to a page, as it just reads easier. Never had an issue with it before, and it wasn't the issue here - I'd just missed the :"") at the end of the line above.

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