Support » Plugin: WP Date and Time Shortcode » Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time s

  • Resolved Veča

    (@marwex)


    Hello, I need some advice.

    When using the shortcode [wpdts-custom start=”post-created” format=”Y”] to display the year in the invoice number, the PDF invoice is not displayed, but an error message:

    Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (post-created) at position 0 (p): The timezone could not be found in the database in /web/wp-content/plugins/wp-date-and-time-shortcode/plugin/classes/WPDateAndTimeShortcode.php:238 Stack trace: #0 /web/wp-content/plugins/wp-date-and-time-shortcode/plugin/classes/WPDateAndTimeShortcode.php(238): DateTime->__construct(‘post-created’) #1 /web/wp-includes/shortcodes.php(355): Denra\Plugins\WPDateAndTimeShortcode->getDateTime(Array, ”, ‘wpdts-custom’) #2 [internal function]: do_shortcode_tag(Array) #3 /web/wp-includes/shortcodes.php(227): preg_replace_callback(‘/\\[(\\[?)(wpdts\\…’, ‘do_shortcode_ta…’, ‘[wpdts-custom f…’) #4 /web/ in /web/wp-content/plugins/wp-date-and-time-shortcode/plugin/classes/WPDateAndTimeShortcode.php on line 238

    Thank you

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Denra.com

    (@denra)

    Hello @marwex,

    Thank you for contacting us. Can you please check which time zone do you have selected in the WordPress General Settings in the admin area and let us know? Also please let us know the following:

    1. WP Date and Time Shortcode plugin version. If you have not updated to version 2.6.1. Please do it and try again.

    2. Your server PHP version. Please make sure that you are using PHP 7.4 or newer.

    Thank you for your patience. We will help you solve your issue.

    Thread Starter Veča

    (@marwex)

    Hello,

    Time zone: Europe / Bratislava

    WP Date and Time Shortcode plugin version: 2.6.1

    PHP version: 7.4

    WordPress version: 6.1.1

    Thank you

    Plugin Author Denra.com

    (@denra)

    Hello again @marwex ,

    The bug was reproduced, found and a new version 2.6.2 of the plugin with the fix is released. The bug was related only to directly set UTC+ and UTC- time zones (not Continent/City ones) in the WordPress General Settings. Please update to the latest version, try again and let us know if all works correctly.

    Thread Starter Veča

    (@marwex)

    Unfortunately, I am unable to update. Error message: Download failed

    Plugin Author Denra.com

    (@denra)

    Hello @marwex,

    The inability to download is not related to our plugin. Please dowload from the repository if needed and then upload for update.

    Thread Starter Veča

    (@marwex)

    Hello,

    Unfortunately, the 2.6.2 update did not fix the problem. 🙁

    Plugin Author Denra.com

    (@denra)

    What is the error you are getting? Is it the same?

    Thread Starter Veča

    (@marwex)

    Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (post-created) at position 0 (p): The timezone could not be found in the database in /web/wp-content/plugins/wp-date-and-time-shortcode/plugin/classes/WPDateAndTimeShortcode.php:245 Stack trace: #0 /web/wp-content/plugins/wp-date-and-time-shortcode/plugin/classes/WPDateAndTimeShortcode.php(245): DateTime->__construct(‘post-created’, Object(DateTimeZone)) #1 /web/wp-includes/shortcodes.php(355): Denra\Plugins\WPDateAndTimeShortcode->getDateTime(Array, ”, ‘wpdts-custom’) #2 [internal function]: do_shortcode_tag(Array) #3 /web/wp-includes/shortcodes.php(227): preg_replace_callback(‘/\\[(\\[?)(wpdts\\…’, ‘do_shortcode_ta…’, ‘[wpdts-custom s…’) #4 /web/wp-content/plugins/wp-date-and-time-shortcode/plugin/classes/WPDateAndTimeShortcode.php on line 245

    Plugin Author Denra.com

    (@denra)

    Please make sure that it is not a cached result. Just in case. Your shortcode works on our side with your time-zone.

    Plugin Contributor Ivaylo Tinchev

    (@itinchev)

    You can see the result here:
    https://prnt.sc/pUpYPku0tlD0

    Plugin Author Denra.com

    (@denra)

    Is it possible that you are trying to generate an invoice number out of the post scope and the plugin cannot get the post data automatically? Please tell us more about your case. We don’t have another complaint until now for such behavior. You may also write by email if it is not convenient to share images and other data here. You may find our email in the admin page of the plugin.

    Plugin Author Denra.com

    (@denra)

    Please let us know if you still need help or we may close the forum thread.

    Thread Starter Veča

    (@marwex)

    Hello,

    the invoice number is displayed correctly on the order list page.

    When you try to open a specific invoice by clicking on the number, you get the error message mentioned in the previous messages.

    The e-shop has been in operation for about two years without any problems. 1,780 orders worth 540,000 euros were placed on the e-shop. The problem appeared only now after some update.

    Plugin Author Denra.com

    (@denra)

    Hello,

    I suppose you are using the shortcode on an invoice generation page where the WordPress function get_the_ID() is not accessing the post ID. So I would suggest that you change the current shortcode by adding the post_id attribute and the ID as number during the generation process.

    [wpdts-custom start="post-created" format="Y" post_id="<the ID of the post>"]

    For example:

    [wpdts-custom start="post-created" format="Y" post_id="6472"]

    If after this change the problem persists, please send us the page URL you are opening and a screenshot with the error. You may use our support email for the purpose.

    Plugin Author Denra.com

    (@denra)

    Hello,

    Is your problem solved? Do you need additional help?

    You may go back to the previous version 2.5.3 if needed, but please note that the year that will be displayed on the invoice page will be the current year and not the year of the invoice if the invoice post ID cannot be taken from the displayed invoice post or from the post_id attribute.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time s’ is closed to new replies.