Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Wrong Date

  • I’m using the following to display the current date but for some reason today it is showing April 3, instead of April 2, any ideas why?

    function current_date_shortcode() {
    return date(‘F d, Y’);
    add_shortcode(‘show_current_date’, ‘current_date_shortcode’);

  • I’m thinking it’s pulling in the UTC time rather than the local time. How do I fix that?

  • Hi there,

    The date() function pulls the current date and time based on the server’s time settings. Try setting your server’s time setting to your local time.

  • The hosting company said there’s no way of doing that and provided this link to figure it out, but I’m not a developer so not really sure what to do. Do I just copy and paste that code to Code Snipets???

  • Hi there,

    in Dashboard > Setting > General – what is the Timezone set to ?

  • Los Angeles

  • Ok, so its either the server as Alvind pointed out.
    Generally it is defined in the php.ini – see here for a example reference on how to set that:

    But the host should really be able to advise on how to do it on their servers, as they may be using some other app to override that.

    Or its a plugin conflict, some plugins may rewrite the date time output.

  • Do you know if this will work using code-snippets:


    $script_tz = date_default_timezone_get();

    if (strcmp($script_tz, ini_get(‘date.timezone’))){
    echo ‘Script timezone differs from ini-set timezone.’;
    } else {
    echo ‘Script timezone and ini-set timezone match.’;

  • No, the code just compares if your timezone setting matches LA.

    If there’s a mismatch, it will output “Script timezone differs from ini-set timezone.”, otherwise, it will output “Script timezone and ini-set timezone match

    It does not change anything.

  • I tried, and it worked.

  • Try using this snippet instead:

    function current_date_shortcode() {
      $timezone = new DateTimeZone( 'America/Los_Angeles' );
      return wp_date("F d, Y", null, $timezone );
    add_shortcode('show_current_date', 'current_date_shortcode');

    Now it should display your local time.

  • Will try, thanks.

  • You’re welcome!

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.