if you like to insert a date f.e. with Weekday and Local Time in your content.
Put this to your child-theme functions.php
function show_date_with_shortcode() {
date_default_timezone_set('Europe/Berlin');
setlocale(LC_TIME, 'de_DE.UTF-8');
$dateInfo = date_i18n( 'l \d\e\n ' . get_option( 'date_format' ) . ' ' . get_option( 'time_format' ). ' \U\h\r' );
return $dateInfo ;
}
add_shortcode( 'show-date', 'show_date_with_shortcode' );
You had to adjust the code to your localisation
date_default_timezone_set : look for example here for more info LINK
setlocale is used – look f.e. here LINK
e.g: setlocale(LC_TIME, 'en_US.UTF-8');
inside the date function you can not use binding words as usual – you had to do it the way above as \t\h\e for the
you use it in your content as [show-date] shortcode.
See example above in copyright info in socket here: https://webers-testseite.de/pureinstall/#footer
with the code above – it shows the german locall date and time and weekdays in german language
It it does not work immediately – maybe you had to activate the shortcode ability for content:
f.e. in child-theme functions.php:
add_filter('widget_text', 'do_shortcode');
add_filter('the_content', 'do_shortcode');
yes – of course this time is only set when loading and is not continuously updated.
This requires other steps to be taken.
but on a page that shows e.g. the opening hours this is a nice additional information.