I can get it to display based on start date/time, but when I set the end date/time it still displays. I know I am doing something wrong. Thought I would post my code.
http://pastebin.com/gxCBHuF5
Since you’ll have access to both the starting time and the ending time, you just need to wrap your link in an if statement. With that if statement, you check if the current time() is greater than the start time, and less than the end time.
if ( ( time() > get_post_meta( get_the_ID(), '_cmb2_live_start_test_datetime_timestamp', true ) && ( time() < get_post_meta( get_the_ID(), '_cmb2_live_end_test_datetime_timestamp', true ) ) { ?>
<a href="#"><span class="fa fa-microphone"></span><span class="listen">Live Broadcast!</span></a>
<?php } ?>
Do I use custom a loop like I have? I inserted it like this and it breaks the site from loading. http://pastebin.com/HJybrSyU
Yes, it’d go in your custom loop. Are you seeing any errors for your “breaking” ? I can’t see any syntax errors in the bit I typed up above, but it may not be completely obvious.
If you can enable WP_DEBUG, that’ll help pinpoint where it’s occurring.
I got it working.
So this usage is UTC which is 6 hours ahead of central time. If I want this to work off the WordPress time setting, I have to be using the test_datetime_timestamp_timezone and have php 5.3 or above correct? Otherwise I have to set the date/time picker 6 hours ahead?
Not too familiar with datetime_timestamp_timezone, as that looks to be a new one in CMB2. Worth tinkering with and trying out to see if it does what you need. Otherwise, there should be ways to manipulate a timestamp to take into account your timezone, before echo to the browser. I also know there are timezone settings available via your php config on the server.
Ahh ok. I will have to do some tinkering to figure it out. Thanks for the help!