L
L
Lyuba2018-04-01 10:09:44
PHP
Lyuba, 2018-04-01 10:09:44

Display the remaining time in the form of a scale?

Good afternoon, tell me how to make the remaining time until the end of the announcement as on Avito in the form of a scale?
I get photo number 2 with this code.

$ost = floor((strtotime($row_Recordset1['data1'])-time())/(24*60*60));
      if($ost>0)
                echo '<br><font color=green>Осталось '.$ost.' дн.</font>';
      elseif($ost==0)
                echo '<br>Последний день';
      elseif($ost<0)
        {
        if (!$row_Recordset1['activ'])
                    echo '<br><font color=red>Просрочено</font>';
        elseif(!$row_Recordset1['moder'])
          {
          echo '<br><font color=orange>В архиве</font>';

5ac085a45d8fa700438806.png5ac085abc9a9f102768916.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Sklyarov, 2018-04-01
@0example

Here is simple arithmetic, plus : Your task is to substitute the total number of days instead, instead of substitute the number of remaining days. However, I would rather translate everything into percentages and output as percentages. In addition, you can create a regular div, put another div in it and set its width in%, which is calculated according to your days. I think how to calculate the percentage of remaining days of the total you know. Example: https://jsfiddle.net/oLnyzLc2/<progress>

I
Igor, 2018-04-01
@stepigor

But what if you use the tag <progress>and set the desired value? I would try.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question