close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Datepicker - European format

Thread began 12/05/2012 11:45 am by thehalpeen319342 | Last modified 1/04/2013 11:20 am by Massimo | 2882 views | 13 replies |

thehalpeen319342

Datepicker - European format

Dear Jason,

I have set the format of my CSS Form Builder datepicker to dd/mm/yyyy. However, when it the date is submitted and then displayed in my browser it displays as 0000-00-00. It also displays like that in the mysql table. Can WebAssist help me to have the record displayed as dd/mm/yyyy ?

Sign in to reply to this post

Jason ByrnesWebAssist

the date format entered in the database must be yyyy-mm-dd


you can convert the date format when the form is submitted by using code similar to this at line (this example assumes the date element is named "date"):

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




on your page, where you display the date, you can convert it to your format using:

php:
<?php echo(date("d/m/Y"strtotime($row_recordsetName("dateColumn"))); ?>
Sign in to reply to this post

thehalpeen319342

Jason, My date element is DOB (Date of Birth). I've tried to replace the DOB section of the insert, but I keep getting syntax errors. What exactly do i need to replace. Below is my insert code:

<?php
// WA DataAssist Insert
if (($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)) // Trigger
{
$WA_connection = $CommSimpleRegister;
$WA_table = "familymembers";
$WA_sessionName = "family_member_ID";
$WA_redirectURL = "welcomepage.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "fKey_Household_id|memberEmail|UserFirstName|UserLastName|UserPhone|memberDOB|memberLineage|photo";
$WA_fieldValuesStr = "".$_SESSION['SecurityAssist_familyID'] ."" . $WA_AB_Split . "".((isset($_POST["Email_Address"]))?$_POST["Email_Address"]:"") ."" . $WA_AB_Split . "".((isset($_POST["First_Name"]))?$_POST["First_Name"]:"") ."" . $WA_AB_Split . "".((isset($_POST["Last_Name"]))?$_POST["Last_Name"]:"") ."" . $WA_AB_Split . "".((isset($_POST["Phone_Number"]))?$_POST["Phone_Number"]:"") ."" . $WA_AB_Split . "".((isset($_POST["DOB"]))?$_POST["DOB"]:"") ."" . $WA_AB_Split . "".((isset($_POST["Lineage"]))?$_POST["Lineage"]:"") ."" . $WA_AB_Split . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."";
$WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,NULL|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_CommSimpleRegister;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id($WA_connection);
if ($WA_redirectURL != "") {
$WA_redirectURL = str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$WA_redirectURL);
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

use the following code at line 1:

php:
<?php

if(isset($_POST['DOB'])) {
    
$_POST['DOB'] = date("Y-m-d"strtotime($_POST['DOB'] ));
}
?>
Sign in to reply to this post

thehalpeen319342

Ok Jason, I forgot to ask you where exactly to put <?php echo(date("d/m/Y", strtotime($row_recordsetName("dateColumn"))); ?> - instead of dateColumn I use memberDOB.

So I've adjusted the code and replaced the following:

value="<?php echo $row_rsMembers_Update['memberDOB']; ?>"


with

value= "<?php echo(date("d/m/Y", strtotime($row_rsMembers_Update("memberDOB"))); ?>"

But I get syntax errors.



Below is my current code (before adjusting)

<span>
<input id="DOB" name="DOB" type="text" value="<?php echo $row_rsMembers_Update['memberDOB']; ?>" class="formTextfield_Medium" tabindex="6" onblur="hideServerError('DOB_ServerError');"/>
<span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldRequiredMsg">Please enter or select a date</span> </span> </span>

Sign in to reply to this post

Jason ByrnesWebAssist

sorry, mixing my square brackets and parenthesis. the correct code would be:

php:
value= "<?php echo(date("d/m/Y"strtotime($row_rsMembers_Update["memberDOB"])); ?>"
Sign in to reply to this post

thehalpeen319342

Jason, Thanks for that, but I'm still getting a syntax error - see attached screenshot.

I've done the following change:

Prior to change:

<span>
<input id="DOB" name="DOB" type="text" value="<?php echo $row_rsMembers_Update['memberDOB']; ?>" class="formTextfield_Medium" tabindex="6" onblur="hideServerError('DOB_ServerError');"/>


After change - adjustment to code:

<span>
<input id="DOB" name="DOB" type="text" value="<?php echo(date("d/m/Y", strtotime($row_rsMembers_Update["memberDOB"])); ?>" class="formTextfield_Medium" tabindex="6" onblur="hideServerError('DOB_ServerError');"/>


Where have I gone wrong?

Attached Files
Update page and Datepicker.pdf
Sign in to reply to this post

Jason ByrnesWebAssist

try changing the code to:
value="<?php echo(date("d/m/Y", strtotime($row_rsMembers_Update['memberDOB'])); ?>"

do you have the same error running the page in your web browser? sometimes Dreamweaver syntax highlighting will show an error when there really is not one.

Sign in to reply to this post

thehalpeen319342

Jason,

I'm still getting the syntax error, and when I check the page in the browser, I am presented with a 'blank' page.

Attached is the php page with value="<?php echo $row_rsMembers_Update['memberDOB']; ?>"

Attached Files
update_member.zip
Sign in to reply to this post

Jason ByrnesWebAssist

I think i see the problem, a missing ) at the end.

try this code:
value="<?php echo(date("d/m/Y", strtotime($row_rsMembers_Update['memberDOB']))); ?>"

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