![]() |
how do you round current time to nearest 15 minutes [Solved] - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: how do you round current time to nearest 15 minutes [Solved] (/showthread.php?tid=53891) |
how do you round current time to nearest 15 minutes [Solved] - El Forum - 08-13-2012 [eluser]Otemu[/eluser] Not exactly a CodeIgniter question but native php but does anyone know how you round current time to nearest 15 minutes I have some simple code displaying current time: Code: echo date('G:i'); Tried some formulas but haven't had much luck so far example 18:27 should display 18:30 Cheers if anyone can help how do you round current time to nearest 15 minutes [Solved] - El Forum - 08-13-2012 [eluser]InsiteFX[/eluser] Found this not sure if it will help. Code: $signintime = '4:32 pm'; how do you round current time to nearest 15 minutes [Solved] - El Forum - 08-13-2012 [eluser]timmahoney[/eluser] I've used this before. $minute = date("i"); $multiplier = round($minute / 15); echo $multiplier * 15; how do you round current time to nearest 15 minutes [Solved] - El Forum - 08-13-2012 [eluser]CroNiX[/eluser] Code: function round_minutes($minutes, $precision = 15) Code: echo round_minutes(date('i')); how do you round current time to nearest 15 minutes [Solved] - El Forum - 08-15-2012 [eluser]Otemu[/eluser] Great help guys, used timmahoney method in end(edit now using InsiteFX method), added switch so 17:59 will now go to 18:00. Code: $minute = date("i"); Actually looking at InsiteFX method probably works better as no need for switch Final Code: Code: $ctime = date('G:i'); |