close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

change date format Datepicker

Thread began 10/14/2013 12:39 pm by J7HNW | Last modified 4/16/2014 5:58 pm by Jason Byrnes | 4647 views | 18 replies |

J7HNW

change date format Datepicker

Please can you tell me how to change the format. Whatever I do with Datepicker - it captures in the format YYYY / MM / DD

It is a UK site and they want it captured to the MySQL in DD/MM/YYYY

Please can you tell me how to achieve this ?

URL is http://www.mottesthighwycombe.co.uk/bookmot.php

John

Sign in to reply to this post

Jason ByrnesWebAssist

the database cannot store the date in that format.

it must store the date in the yyyy-mm-dd format.

you change the format that is used to display the date on the individual pages using the date function though.

so instead of using:

<php echo $row_recordsetName['dateColumn']; ?>

to write the date to the page, use:
<php echo(date("d/m/Y", strtotime($row_recordsetName['dateColumn']))); ?>

Sign in to reply to this post

J7HNW

Date Format

Hi Jason and thanks for your e mail

Problem is when somebody SELECTS the date from the datepickers on the form - it puts it on the form in YYYY MM DD onto the form
and this is where I Want it to view DDMMYYYY

I have searched for the code you gave me to replace in the source code on the form page - but dreamweaver cannot find this code ?

Please advise

Sign in to reply to this post

Jason ByrnesWebAssist

send a copy of the page please.

Sign in to reply to this post

J7HNW

Attached thanks Jason

Attached Files
bookmot.php
Sign in to reply to this post

Jason ByrnesWebAssist

theres no spry, so the format only needs to be changed for the date picker.

find this line:

dateFormat:"yy-mm-dd"

to change the format:
dateFormat:"dd-mm-yy"


but remember, the date that gets inserted to the database must be in the yyyy-mm-dd format, so code will need to be added to change the format that is passed. the code will be similar to this:

<?php
if(isset($_POST['dateField'])) $_POST['dateField'] = date("Y-m-d", strtotime($_POST['dateField']));
?>

Sign in to reply to this post

J7HNW

Hi Jason

Great now works perfectly on the page - you select date which is shown in UK format eg 15/11/2013

Added the PHP code you gave me to switch the date to YYYYMMDD

It now inputs all dates as 01/1/1970

MySQL field is set as DATE

Page attached again - have I done something wrong ?

John

Attached Files
bookmot.php
Sign in to reply to this post

Jason ByrnesWebAssist

I dont see the php code for changing the date format back to Y-m-d on your page.

add the following code at line 1:
<?php
if(isset($_POST['PreferredDate'])) $_POST['PreferredDate'] = date("Y-m-d", strtotime($_POST['PreferredDate']));
?>

Sign in to reply to this post

J7HNW

Thanks Jason

Added your code twice ( once for each datepicker ) and perfect. Now logs properly on page and into MySQL

<?php
if(isset($_POST['PreferredDate'])) $_POST['PreferredDate'] = date("Y-m-d", strtotime($_POST['PreferredDate']));
?>
<?php
if(isset($_POST['PreferredDate'])) $_POST['MotExpiry'] = date("Y-m-d", strtotime($_POST['MotExpiry']));
?>


Only remaining problem is e mail form sent shows wrong way. DO I embed the same code into the
page waue_bookmot_3.php or into the form sent by UEMail ( Blank_4.php ) please

Kind regards and thank you for your help

John

Sign in to reply to this post

Jason ByrnesWebAssist

add code to the email template file Blank_4.php to change the date format back:

<?php
if(isset($_POST['PreferredDate'])) $_POST['PreferredDate'] = date("d-m-Y", strtotime($_POST['PreferredDate']));
?>
<?php
if(isset($_POST['PreferredDate'])) $_POST['MotExpiry'] = date("d-m-Y", strtotime($_POST['MotExpiry']));
?>

Sign in to reply to this post
loading

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