close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

On my update page the date shows in the update form field as 2022-03-21. Can you please advise on how to display as 03-21-2022?

Thread began 4/05/2022 7:18 am by jo271221 | Last modified 4/05/2022 2:58 pm by Ray Borduin | 588 views | 7 replies |

jo271221

On my update page the date shows in the update form field as 2022-03-21. Can you please advise on how to display as 03-21-2022?

We discussed this in our session yesterday and I forgot about it.
I have attached the page. The column names are eventdate and enddate

Thank you for the help yesterday. I really appreciate it!

Sign in to reply to this post

Ray BorduinWebAssist

You should use 03/21/2022, not with dashes. Dashes are recognized as the european format and will be understood as day-month-year instead of month/day/year.

The formatting can be done with the date function like:

<?php echo(date("m/d/Y",strtotime($Recordset->getColumnVal("dateField")))); ?>

Sign in to reply to this post
Did this help? Tips are appreciated...

jo271221

Thank you,

Can you please update the code below for me. I attempted and failed miserably. This is on an update page.

Sign in to reply to this post

Ray BorduinWebAssist

php:
<input id="enddate" name="enddate" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("updateraceinfo","enddate"):date('m/d/Y',strtotime($WADAtbl_posts_update->getColumnVal("enddate"))))); ?>" title="Please enter a value.">
Sign in to reply to this post
Did this help? Tips are appreciated...

jo271221

For some reason the update is not working correctly. I now have 11/30/-0001 instead of 4/5/2022

Sign in to reply to this post

Ray BorduinWebAssist

Make sure your datatype in your Update Server Behavior is set to date for those columns. It looks like you have it set to string.

Sign in to reply to this post
Did this help? Tips are appreciated...

jo271221

After quite a bit of trial and error I realized that I also need to update the update behavior to allow the insert in that format. I was unable to do with the date format but this seems to work. It will work 4/5/22. Obviously ignoring the hour, minute, second.

Do you have a better solution?

$UpdateQuery->bindColumn("eventdate", "t", "".((isset($_POST["eventdate"]) && $_POST["eventdate"]!="" )?date("Y-m-d H:i:s", strtotime($_POST["eventdate"])):"") ."", "WA_DEFAULT");

$UpdateQuery->bindColumn("enddate", "t", "".((isset($_POST["enddate"]) && $_POST["enddate"]!="" )?date("Y-m-d H:i:s", strtotime($_POST["enddate"])):"") ."", "WA_DEFAULT");

This did not work
$UpdateQuery->bindColumn("enddate", "t", "".((isset($_POST["enddate"]) && $_POST["enddate"]!="" )?date("m-d-Y", strtotime($_POST["enddate"])):"") ."", "WA_DEFAULT");

Sign in to reply to this post

Ray BorduinWebAssist

I warned you that using dashes would cause problems because php recognizes it as European format: D-M-Y. That is why your final example wouldn't work.

You shouldn't need to reformat it in the bindColumn(). The webassist function should do that automatically if you use "t" data type. I think this would work:
$UpdateQuery->bindColumn("eventdate", "t", "".(isset($_POST["eventdate"])?$_POST["eventdate"]:"") ."", "WA_DEFAULT");

Sign in to reply to this post
Did this help? Tips are appreciated...

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