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