close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Start DATETIME & End DATETIME from recordset headache...how to display content depending if one is greater than the other?

Thread began 11/16/2016 10:28 am by Nathon Jones Web Design | Last modified 11/16/2016 4:35 pm by Nathon Jones Web Design | 349 views | 1 replies

Nathon Jones Web Design

Start DATETIME & End DATETIME from recordset headache...how to display content depending if one is greater than the other?

I have an events table with a start datetime and an end datetime field. As usual, I'm probably making this more complicated than it needs to be so bear with me!

I've set both the start and end datetime fields to be the current timestamp. Only the start date is required to be entered by the user. The end date is optional, where events need an end time or for events that span two or more days.

If the user only enters a start date, the start datetime in the table will be greater than the end datetime. I then only want to display the start date to the user which works fine:

<?php if ($rsEVENTS->getColumnVal("eventSTART") > $rsEVENTS->getColumnVal("eventEND")) { ?>
<?php echo($rsEVENTS->getColumnVal("eventSTART")?date("l jS F Y",strtotime($rsEVENTS->getColumnVal("eventSTART"))):""); ?>
<?php } ?>



Is the user does enter an end date, 24 hours or more later than the start date, I want to display the start date and end date to the user which also works fine:

<?php if ($rsEVENTS->getColumnVal("eventSTART") < $rsEVENTS->getColumnVal("eventEND")) { ?>
<?php echo($rsEVENTS->getColumnVal("eventSTART")?date("l jS F",strtotime($rsEVENTS->getColumnVal("eventSTART"))):""); ?> - <?php echo($rsEVENTS->getColumnVal("eventEND")?date("l jS F Y",strtotime($rsEVENTS->getColumnVal("eventEND"))):""); ?>
<?php } ?>



However, if the user enters an end datetime but it's within 24 hours of the start datetime, I only want to display the following

Start Day & Month
Start Time - End Time

I don't want to have to add two more fields for the user to have to complete - start time and end time - as they are happy with the date/time jQuery picker that's currently installed.

Hoping someone can throw a bucket of cold water over me with the solution, thank you.
NJ

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