close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

if date/time from recordset is less than or equal current date? Is this even possible?

Thread began 7/05/2016 8:30 am by Nathon Jones Web Design | Last modified 7/05/2016 11:54 am by Ray Borduin | 1053 views | 3 replies |

Nathon Jones Web Design

if date/time from recordset is less than or equal current date? Is this even possible?

I have a recordset on a page and one of the fields is a datetime field from MySQL database.

I want to display some text on the page if the date from the recordset is less than the current date, and alternative text if the date is greater than the current date. I have tried what feels like a thousand combinations of solutions and eventually landed at...

<?php if (date("j F Y",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventEND"))) < date()) { ?>
<h6><?php
echo($rsCONFIRMEVENT->getColumnVal("DGCRCeventSTART")?date("j F Y",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventSTART"))):"");
?></h6>
<?php } ?>


<?php if (date("j F Y",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventEND"))) > date()) { ?>
<h6><?php
echo($rsCONFIRMEVENT->getColumnVal("DGCRCeventSTART")?date("j F",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventSTART"))):"");
?> - <?php
echo($rsCONFIRMEVENT->getColumnVal("DGCRCeventEND")?date("j F Y",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventEND"))):"");
?></h6>
<?php } ?>



The date from the recordset is most definitely less than the current date but it doesn't display either sections of text.
I really struggle to understand why date formats are so complicated in database setups and I think I've probably completely wrecked it by doing a strtotime.
I'd appreciate any help anyone could offer.

Thank you.
NJ

Sign in to reply to this post

Nathon Jones Web Design

Eh?

Just noticed that when I do this on a page:
<?php echo date("j F Y h:m:s");?>

...it's 12 hours and 43 minutes out!

Man, I'm so confused right now. Is my server wrecked?
Would really appreciate some help. Thank you.
NJ

Sign in to reply to this post

Nathon Jones Web Design

Take two...

Added this in the head, but I don't understand why I need to do this...

<?php date_default_timezone_set('Europe/London'); ?>



What happens if someone visits the page who isn't in the Europe/London timezone?

Then I changed my date display code to the following...

<?php if (date("j F Y G:m:s",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventEND"))) < date("j F Y G:m:s")) { ?>
<h6><?php
echo($rsCONFIRMEVENT->getColumnVal("DGCRCeventSTART")?date("j F Y",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventSTART"))):"");
?></h6>
<?php } ?>

<?php if (date("j F Y G:m:s",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventEND"))) > date("j F Y G:m:s")) { ?>
<h6><?php
echo($rsCONFIRMEVENT->getColumnVal("DGCRCeventSTART")?date("j F",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventSTART"))):"");
?> - <?php
echo($rsCONFIRMEVENT->getColumnVal("DGCRCeventEND")?date("j F Y",strtotime($rsCONFIRMEVENT->getColumnVal("DGCRCeventEND"))):"");
?></h6>
<?php } ?>



...which works.

I thank me.
NJ

Sign in to reply to this post

Nathon Jones Web Design

This post has been deleted.

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