By default, and without any attributes, the shortcode will display the countdown to NYE. For example,
[days] returns: 6 months. Because we're using WP's human readable functions, the rendering isn't overly descriptive. For example, Christmas day in 2030 (using
[days date="25th December 2030"] will show as 8 years. When an expiry has passed (using our last webinar as an example), it will show as
passed (5 years ago). The text of 'passed' is determined by a shortcode attribute (I've added
del tags to mine).
To link your result, use the
url attribute. The full date will be returned in the HTML title attribute.
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.
The following shortcode attributes are available.
textis what will be rendered when your time has passed.
style="something: something;"to style the result.
offsetis not defined, we'll use your offset as stored in your WP database. We use
A PHP function to be used outside of WordPress is as follows. Usage requires beliefmedia_human_time_diff().
The offset (in hours) is required when a correction must be applied to your resulting result. To test, set a time one hour in the future and note the difference. The way of determining the offset is a little counter-intuitive (since the intent is manufacture a UTC offset). A negative offset will mean the value will be added to your result.
- See also: Display Time To Published or Scheduled Posts (WP Snippet).