K
K
Klayn242015-11-20 13:55:31
PHP
Klayn24, 2015-11-20 13:55:31

How to display time in a graph?

Good day.
I have received time that I spent on any project. Let's say I spent 1 day, 2 hours, 3 minutes and 26 seconds on the first and second projects. Data is stored in variables:

$day = 2;
$hour = 2;
$min = 3;
$sec = 26;

How can I display such data in a graph? If these were integers (as in the picture), then this is easy to deduce, but I don’t understand how to do it for time.
606df2dd5ea2419691ae38267b879fc5.png
I think that everything needs to be converted into hours and then substituted into the chart, approximately according to the following formula (taken on this site ):
4.28 hours = 4.28 * 60 = 256.8 minutes
Thus, I want to display to the user how much he spent time for your projects.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Ernest Faizullin, 2015-11-20
@Klayn24

time scale in hours

$hours = $days*24 + $hour + $min/60 + $sec/3600;
$hours = round($hours);

$timeline = range(1, $hours); // [1, 2, 3, ... $hours]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question