Skip Navigation

[Closed] Is there a way to show html based on condition of the current Eastern time?

This support ticket is created 6 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.65 hours from now. Thank you for your understanding.


This topic contains 3 replies, has 2 voices.

Last updated by Shane 6 years, 12 months ago.

Assigned support staff: Shane.


I am trying to: Show conditional HTML based on the current time of day in New York

I visited this URL:

I expected to see:

Instead, I got:

is it possible to show conditional HTML in a Content Template or View ,based on the current time in NYC (Eastern Time)?

if it's before 5am, I want to show certain content, if it's later than 5am, i want to show alternate content.

I want to avoid the user having to input a custom field date.

Is this possible? Thanks in advance for your help 🙂



Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Katrina,

Thanks for contacting our support forum.

I believe this is possible by using some custom code to get the current time and compare it to a fixed time.

However to confirm my assumption I would need to perform some tests before giving you a definitive answer.

I'll get back to you once i've done this test.



Hi Shane,

That sounds promising! Please let me know what you discover...

Thank you for taking the time.




Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Katrina,

So i've found a way to make this work for you.

Add this to your theme's functions.php file.

// Add Shortcode
function new_time() {

  // Code
ini_set('date.timezone', 'America/New_York');

$time = date('H', time()); // 12:00:00

return $time;

add_shortcode( 'new_time', 'new_time' );

The next step is to go to views -> settings -> compatibility and add "new_time" to the 3rd party shortcodes argument area.

Once you have done that then you can use the following shortcode.

[wpv-conditional if="( '[new_time]' lt '5' )"]It's time[/wpv-conditional]

[wpv-conditional if="( '[new_time]' gt '5' )"]It's not time[/wpv-conditional]

The first one is for all the content before 5am and the second is for content after 5am.

Please let me know if this helps.


The topic ‘[Closed] Is there a way to show html based on condition of the current Eastern time?’ is closed to new replies.