🙂 So I do have edited some code I found online to this:
function timeZone_funch( $atts )
{
extract(shortcode_atts(array('timezone' => 'Europe/Berlin'), $atts));
/* Europe/Berlin is default Timezone */
$output = '';
if (in_array($timezone, DateTimeZone::listIdentifiers()))
{
date_default_timezone_set($timezone);
$currentTime = date( 'H:i', strtotime('+30 minutes'));
$output = $currentTime;
}
else {
$output = "Invalid Timezone";
}
return $output;
}
add_shortcode( 'current_time', 'timeZone_funch' );
It works as it should. It displays the timezones hour and minute + adding 30 minutes.
What I want to do now is to make it round up to the nearest quater hour.
Similar to this thread: Round minute down to nearest quarter hour
I also believe that this thread contains my answer BUT due to my lack of knowledge and experience, I’m not able to work the code from the thread above into the code I have right now.
If anybody could show me how I can integrate it, this would be amazing!
Thank you for your time and maybe even your answer!
With kind regards
Chris
Finding the correct way to integrate the round up function inside of the code I’am using.
2
Answers
Here is the solution that worked! Thanks again to D.Dimopoulos! :-)