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

Input Date in Euro Format

Thread began 8/28/2009 7:28 am by kirk319254 | Last modified 2/04/2010 7:05 pm by Jason Byrnes | 3735 views | 7 replies |

kirk319254

Input Date in Euro Format

Good afternoon,

I have been searching in how to input the date into mysql in a Euro format (dd/mm/yyyy. I appreciate that mysql uses (yyyy/mm/dd). I do not mind it being in this format in the database but would like to make it more user friendly when inputing the dates.
I own Admin Suite (Site Assist -Data Assist-Security Assist-Cookies Toolkit- Digital File Pro) Is there any way I could use any of these products to accomplish this easy. ( I know as a back up plan I could validate the fields with ajax in Dreamweaver and force them to input in the Mysql format yyyy/mm/dd)

I am very new to this and use Dreamweaver to do all the work behind the scenes which means my knowledge of PHP is limited so any guidance or advice will be appreciated.

Thank you,

Kirk

Sign in to reply to this post

Jason ByrnesWebAssist

When dealing with dates in MySQL With PHP, I like to store the date as the PHP Time stamp in an Integer column. The php time stamp is the number of seconds from January 1, 1970 to the date entered.

On the insert, you can use the PHP strtotime() function to convert the date that is entered to the php time stamp.


In DataAssist, when you bind a column to a form element, you get code like:

php:
<?php echo ((isset($_POST["dateElement"]))?$_POST["dateElement"]:""); ?>



change this to:

php:
<?php echo ((isset($_POST["dateElement"]))?strtotime($_POST["dateElement"]):""); ?>



to convert the entered date to a php time stamp. so if the enter:
2/2/2009

The value stored in the database is:
1233561600



when you pull the information out of the database, you can convert it from the time stamp to the date using the date function. for example:

php:
<?php echo date("d/m/Y"$row_RecordsetName['DateColumn']); ?>




will convert the time stamp to the DD/MM/YYYY format.

more information on the strtotime() and date() functions can be found here:
strtotime
function.date.php

Sign in to reply to this post

kirk319254

Date Input Euro Style

Hi Jason,

Sorry for the delays in replying but things have been hectic (not good hectic)

I appreciate the time stamp advice but the only concern I have which I did not mention in the first post is that I am trying to set up a database for our small library and thought it would at a later stage be able to be put on the net.

The only thing is that we have some books dating back hundreds of years with one even being in the 1600's so am not sure if the time stamp will work.

But being a newbie in I could be wrong.

Any ideas gratefully received.

Thank you,

Kirk

Sign in to reply to this post

Jason ByrnesWebAssist

No the time stamp wont work in this instance.


On the form where the users enter the information use Validation Toolkit to apply Client side validation.

Use Date time client side validation to validate the entered date.

Set ti to allow mm/dd/yyyy to be entered.

And set the reformat option to yyyy/mm/dd. This will convert the entered date to the MySQL Format when the form is submitted.

Sign in to reply to this post

jw291405

Hi Jason,

Does the validation solution you suggest mean that the integer date column is no longer necessary?

Thanks.

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, that's correct. You would use a standard date column.

Sign in to reply to this post

dlovas275157

Jason/Kirk,

I have followed the instructions in this thread, and the "timestamp" version discussed works great. However, I cannot get the "date" version working. I need the "date" version for date prior to 1970. (euro not needed, just a basic date version). My mysql database column is formatted as "date" 0000-00-00.

Could you please let me know if you ever got this working, and what I am possible doing wrong.

Steps I took:
1. Generated insert form with DataAssist
2. Added datepicker to date field using CSS Form Builder
3. Re-Binded Insert SB to new CSS Form Recordset values
4. Applied client side validation on date field (allow mm/dd/yyyy) and reformat to (yyyy/mm/dd) I also tried reformat to (yyyy-mm-dd) via Behaviors Panel > WA Validation Toolkit > Apply Client Validations > Date/Time.

On form submission, displays "invalid format" and will not submit.

Attached is my code and screenshots.

Thanks for any help. D.

Attached Files
bluesky_date_Insert.php.zip
Sign in to reply to this post

Jason ByrnesWebAssist

you will need to use the yyyy-mm-dd format for both the Client side validation and the spry Validation.

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