Created
September 8, 2016 07:01
-
-
Save YaroslavShapoval/dd0fc7f05664ac21df27db7821d84787 to your computer and use it in GitHub Desktop.
Generate random data for highcharts
This file contains hidden or 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 | |
| $begin = new Datetime(); | |
| $begin->modify('first day of this month'); | |
| $begin->setTime(0,0,0); | |
| $end = new Datetime(); | |
| $end->modify('last day of this month'); | |
| $end->setTime(23,59,59); | |
| $offset = $begin->getOffset(); | |
| $interval = new DateInterval('P1D'); | |
| $daterange = new DatePeriod($begin, $interval ,$end); | |
| $data = []; | |
| foreach($daterange as $date) { | |
| $number = mt_rand(0, 5); | |
| $data[] = "[" . ($date->getTimestamp() + $offset) * 1000 . ", " . $number . "]"; | |
| } | |
| echo implode(",<br>", $data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment