Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $current_month = date('m'); $current_quarter_start = ceil($current_month/4)*3+1; // get the starting month of the current quarter echo $start_date = date("Y-m-d H:i:s", mktime(0, 0, 0, $current_quarter_start, 1, date('Y') )); echo $end_date = date("Y-m-d H:i:s", mktime(0, 0, 0, $current_quarter_start+3, 1, date('Y') )); // by adding or subtracting from $current_quarter_start within the mktime function you can get any quarter of any year you want. // return array($start_date, $end_date); // print_r($months);
Copy Clear