zoukankan      html  css  js  c++  java
  • php 代替 js实现自定义时间选择器

    w

    0-php来结合服务端数据,处理前端页面的交互;

    1-php 加法 乘法的效率对比,对算术运算的优化。

    减少乘法运算?

    function w_select($wname, $wii)
    {
        $w = '<select class="form-control" name="' . $wname . '">';
        $wtmphour = intval(substr($wii, 0, strlen($wii) - 2));
        $wtmp30 = intval(substr($wii, strlen($wii) - 2, 2));
    
        $wtmphourb = $wtmphour;
        if ($wtmphour > 12) $wtmphourb = $wtmphour - 12;
        if ($wtmp30 == 0) {
            $wv = $wtmphour * 3600;
            $w .= ' <option value="' . $wv . '" >' . $wtmphourb . ':00</option>';
        }
        $wv = $wtmphour * 3600 + 1800;
        $w .= ' <option value="' . $wv . '" >' . $wtmphourb . ':30</option>';
        $wtmphour += 1;
    
        if ($wtmphour <= 12) {
            for ($wl = $wtmphour; $wl <= 12; $wl++) {
                $wv = $wl * 3600;
                $w .= ' <option value="' . $wv . '" >' . $wl . ':00' . '</option>';
                $wv = $wl * 3600 + 1800;
                $w .= ' <option value="' . $wv . '" >' . $wl . ':30' . '</option>';
            }
    
            for ($wl = 1; $wl <= 8; $wl++) {
                $wv = $wl * 3600 + 12 * 3600;
                $w .= ' <option value="' . $wv . '" >' . $wl . ':00' . '</option>';
                $wv = $wl * 3600 + 1800 + 12 * 3600;
                $w .= ' <option value="' . $wv . '" >' . $wl . ':30' . '</option>';
            }
    
        } else {
            for ($wl = $wtmphour - 12; $wl <= 8; $wl++) {
                $wv = $wl * 3600 + 12 * 3600;
                $w .= ' <option value="' . $wv . '" >' . $wl . ':00' . '</option>';
                $wv = $wl * 3600 + 1800 + 12 * 3600;
                $w .= ' <option value="' . $wv . '" >' . $wl . ':30' . '</option>';
            }
        }
    
        $w .= ' <option value="9:00">9:00</option>';
        $w .= ' </select>';
        return $w;
    }

  • 相关阅读:
    windows系统下强制杀死某个进程
    onenote快捷键
    sublime封装代码块快捷键、eemet插件安装、Loading PyV8 binary...的解决办法
    google浏览器截长图的方法
    (转)Java基础加强之并发(二)常用的多线程实现方式
    hibernate学习(初识)
    Spring中的事务操作
    JDBC最原始的代码做查询操作
    Spring的JDBC模板
    Spring AOP
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6480650.html
Copyright © 2011-2022 走看看