Hello @generosus,
Thank you for using our plugin. You can always use your own code snippet, but it might be difficult to achieve other functionalities of the plugin in such cases, if they are needed.
Here is a sample snippet for shortcode in your special case(s):
add_shortcode('wpdts_snippet_date_time', 'wpdts_custom_fnc');
function wpdts_custom_fnc($atts, $content, $tag) {
$atts_default = [
'tag' => 'span', // The default result tag attribute.
'format' => 'G:m A', // The default result tag attribute.
];
$timestamp = current_time('timestamp'); // The current UNIX timestamp according to the time zone.
// Get the shortcode attributes.
$atts = shortcode_atts(
$atts_default,
$atts,
$tag
);
$custom_date_time = date_i18n($atts['format'], $timestamp, false); // The internationalized date and/or time value for the symbols.
$result = ''; // The result string, which may ot may not be resturned as an HTML tag content.
if ($atts['tag']) {
$result .= "<{$atts['tag']} class=\"wpdts-snippet-date-time\">";
}
$result .= $custom_date_time;
if ($atts['tag']) {
$result .= "</{$atts['tag']}>";
}
return $result;
}
You can use the new shortcode like this:
[wpdts_snippet_date_time format="G:m A"]
[wpdts_snippet_date_time tag="" format="G:m A"]
[wpdts_snippet_date_time tag="p" format="Y-m-d H:i:s"]
You just need to change the tag
(for HTML tag, if needed; the default is <span>
) and the format
attributes (using the symbols for the date_i18n
function).