几个月的一轮实验

时间:2017-12-06 08:06:32

标签: php laravel datetime

我正在节省员工的工作经验,例如5.14 n,当我展示它时,它应该显示为6.2yrs的实验;

如何在PHP或laravel框架中计算它?

2 个答案:

答案 0 :(得分:0)

如果你的意思是6.14来向上舍入到6.2。

您可以使用PHP的以下功能:

function round_up($e)
{
    $e = explode(".", $e);
    $e[1] = ceil($e[1] / 10);
    return implode(".", $e);
}

使用ceil()函数,您可以舍入到下一个最高整数值。请参阅regex demo

如果您的意思是5.14,则可以达到6.2(如14个月)。您可以使用以下功能:

function round_up($e)
{
    $e = explode(".", $e);
    $e[0] = $e[0] + round($e[1] / 12);
    $e[1] = $e[1]%12;
    return implode(".", $e);
}

答案 1 :(得分:0)

将5.14视为字符串我为您创建了简单的功能

    @-moz-keyframes bounce {
      0%, 20%, 50%, 80%, 100% {
        -moz-transform: translateY(0);
        transform: translateY(0);
      }
      40% {
        -moz-transform: translateY(-30px);
        transform: translateY(-30px);
      }
      60% {
        -moz-transform: translateY(-15px);
        transform: translateY(-15px);
      }
    }
    @-webkit-keyframes bounce {
      0%, 20%, 50%, 80%, 100% {
        -webkit-transform: translateY(0);
        transform: translateY(0);
      }
      40% {
        -webkit-transform: translateY(-30px);
        transform: translateY(-30px);
      }
      60% {
        -webkit-transform: translateY(-15px);
        transform: translateY(-15px);
      }
    }
    @keyframes bounce {
      0%, 20%, 50%, 80%, 100% {
        -moz-transform: translateY(0);
        -ms-transform: translateY(0);
        -webkit-transform: translateY(0);
        transform: translateY(0);
      }
      40% {
        -moz-transform: translateY(-30px);
        -ms-transform: translateY(-30px);
        -webkit-transform: translateY(-30px);
        transform: translateY(-30px);
      }
      60% {
        -moz-transform: translateY(-15px);
        -ms-transform: translateY(-15px);
        -webkit-transform: translateY(-15px);
        transform: translateY(-15px);
      }
    }
    body {
      background: black;
    }

    .arrow {
      position: fixed;
      bottom: 0;
      left: 50%;
      margin-left: -20px;
      width: 40px;
      height: 40px;
      background-image: url(data:image/svg+xml;base64,PD94bW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5NWwwLDBjMjAuNTA5LTIwLjUwOCwyMC43NzQtNTMuNDkzLDAuNTk2LTczLjY3MiAgbC0xOTAtMTkwYy0yMC4xNzgtMjAuMTc4LTUzLjE2NC0xOS45MTMtNzMuNjcxLDAuNTk1bDAsMGMtMjAuNTA4LDIwLjUwOS0yMC43NzIsNTMuNDkyLTAuNTk1LDczLjY3MUwyMjAuMjQ5LDQ1NS44Njh6Ii8+DQo8L3N2Zz4=);
      background-size: contain;
    }

    .bounce {
      -moz-animation: bounce 2s 1;
      -webkit-animation: bounce 2s 1;
      animation: bounce 2s 1;
    }