mysqlDate2JsTimestamp() public static method

Convert mysql format datetime to JS timestamp (milliseconds since unix epoch).
public static mysqlDate2JsTimestamp ( string $value ) : float
$value string
return float
 public function run()
 {
     $chart = $this->createWidget('FlotChart', array('chart_id' => 'iop-history-chart'))->configureChart(array('colors' => array('#4daf4a', '#984ea3', '#4daf4a', '#984ea3')))->configureXAxis(array('mode' => 'time'))->configureYAxis('mmHg', array('min' => 0, 'max' => 80))->configureSeries('RE', array('points' => array('show' => true), 'lines' => array('show' => true)))->configureSeries('LE', array('points' => array('show' => true), 'lines' => array('show' => true)))->configureSeries('Target RE', array('colors' => array("#fff", "#fff", "#fff"), 'points' => array('show' => true), 'dashes' => array('show' => true, 'style' => array(6))))->configureSeries('Target LE', array('points' => array('show' => true), 'dashes' => array('show' => true, 'style' => array(6))));
     $events = $this->event_type->api->getEventsInEpisode($this->episode->patient, $this->episode);
     foreach ($events as $event) {
         if ($iop = $event->getElementByClass('OEModule\\OphCiExamination\\models\\Element_OphCiExamination_IntraocularPressure')) {
             $timestamp = Helper::mysqlDate2JsTimestamp($event->event_date);
             $this->addIop($chart, $iop, $timestamp, 'right');
             $this->addIop($chart, $iop, $timestamp, 'left');
         }
     }
     $plan = $this->event_type->api->getMostRecentElementInEpisode($this->episode->id, $this->event_type->id, 'OEModule\\OphCiExamination\\models\\Element_OphCiExamination_OverallManagementPlan');
     if ($plan) {
         $this->addTargetIop($chart, $plan, 'right');
         $this->addTargetIop($chart, $plan, 'left');
     }
     $this->render('OphCiExamination_Episode_IOPHistory', array('chart' => $chart));
 }
 /**
  * @param Event                                 $event
  * @param \FlotChart                            $chart
  * @param OphCiExamination_VisualAcuity_Reading $reading
  * @param string                                $side
  */
 protected function addVaReading($event, \FlotChart $chart, models\OphCiExamination_VisualAcuity_Reading $reading, $side)
 {
     $series_name = "Visual Acuity ({$side})";
     $label = "{$series_name}\n{$reading->element->unit->name}: {$reading->convertTo($reading->value)} {$reading->method->name}";
     $chart->addPoint($series_name, Helper::mysqlDate2JsTimestamp($event->event_date), $reading->value, $label);
 }
 /**
  * @param \FlotChart $chart
  * @param string $va_axis
  * @param array $injection
  * @param string $side
  * @param float|null &$injMin
  * @param float|null &$injMax
  */
 protected function addInjection(\FlotChart $chart, $va_axis, array $injection, $side, &$injMin, &$injMax)
 {
     $drug = $injection["{$side}_drug"];
     $timestamp = Helper::mysqlDate2JsTimestamp($injection['date']);
     $chart->configureSeries($drug, array('yaxis' => $va_axis, 'bars' => array('show' => true)));
     $chart->addPoint($drug, $timestamp, 149);
     $this->injections[$timestamp][$side] = $drug;
     if ($side == 'right' && (!$injMin || $timestamp < $injMin)) {
         $injMin = $timestamp;
     }
     if ($side == 'left' && (!$injMax || $timestamp > $injMax)) {
         $injMax = $timestamp;
     }
 }
コード例 #4
0
 /**
  * @dataProvider mysqlDate2JsTimestampDataProvider
  */
 public function testMysqlDateToJsTimestamp($input, $output)
 {
     $this->assertEquals($output, Helper::mysqlDate2JsTimestamp($input));
 }