https://developers.google.com/chart/interactive/docs/datesandtimes<?php
$connection = mysqli_connect('localhost', 'xxxx', 'xxxx', 'database');
$result = mysqli_query($connection, "SELECT id, date, value FROM table");
?>
<html>
<head>
<script type="text/javascript" src="
https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Time of Day');
data.addColumn('number', 'Rating');
data.addRows([
<?php
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_array($result)) {
$datum = $row['date'];
$ertek = $row['value'];
?> [new Date( <?php echo $row['date']; ?> ), <?php echo $row['value']; ?> ], <?php
}
}
?>
]);
var options = {
title: 'Rate the Day on a Scale of 1 to 10',
width: 900,
height: 500,
hAxis: {
format: 'Y/m/d h:m:s',
gridlines: {count: 15}
},
vAxis: {
gridlines: {color: 'none'},
minValue: 0
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
var button = document.getElementById('change');
button.onclick = function () {
// If the format option matches, change it to the new option,
// if not, reset it to the original format.
options.hAxis.format === 'M/d/yy' ?
options.hAxis.format = 'MMM dd, yyyy' :
options.hAxis.format = 'M/d/yy';
chart.draw(data, options);
};
}
</script>
</head>
<body>
<div id="chart_div"></div>
</body>
</html>