Current Date Time Zone

Hi there,
I used the following code to create a current date and time shortcode:

// Date Shortcode 
add_shortcode( 'current_date', 'func_current_date' );
function func_current_date(){
  return date('l, F j, Y');
}

But It pulls up one time zone. Can this be set to show the time zone of the current user?

Hi @suzannereid,

Unfortunately, the feature you are talking about is not related to our product and is considered as custom development and outside of our support scope.

The current user Time Zone can not be retrieved via PHP as PHP is a server-side language and it can have access to the server Time Zone. You will need to have a Javascript code to retrieve the current user and then use it on your code.

The example below can be a good starting point:

I also performed a Google Search that might help you get started with your research to implement the feature.

Thank you,

1 Like

Gotcha. We just ended up setting it to the EST time zone. :slight_smile: thanks!

We are delighted to assist you with this.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.