Last active
March 25, 2024 02:27
-
-
Save jasperfrontend/a83a712e1087a63b34d07fccfe11eddc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// My time shortcode [mytime timezone="Europe/Amsterdam" format="h:i A"] | |
// You can also edit the defaults on lines 7 & 8, then you can just use [mytime] to show your current time | |
add_shortcode( 'mytime', 'imw_my_time' ); | |
function imw_my_time( $atts ) { | |
$atts = shortcode_atts( array( | |
'timezone' => 'Europe/Amsterdam', | |
'format' => 'h:i A' | |
), $atts, 'mytime' ); | |
$timezone = new DateTimeZone( $atts['timezone'] ); | |
$return = wp_date($atts['format'], null, $timezone ); | |
return $return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment