日历控件,可以在此基础上做更多的扩展,如实现行程安排等
<html> <head> <title>日历控件</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style" content="black"/> <style type="text/css"> .rili { margin: 30px 0px; overflow: hidden; text-align: center; color: #666 } .low_calendar { overflow: hidden; border: 1px solid #c8d2dc; } .low_calendar h1 { width: 100%; background: #ff6f7e; font-size: 14px; height: 30px; line-height: 30px; text-align: center; color: #fff; font-weight: 100; box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); position: relative } .calGrid table { width: 100%; border-collapse: collapse; margin: 0; padding: 0; } .calGrid table th { background-color: #fff; border-left: 1px solid #whiteSmoke; font-size: 12px; height: 30px; line-height: 30px; text-align: center; vertical-align: middle; color: #999; color: #505050; border-bottom: 1px solid #C8C8C8; } .calGrid table td { width: 12%; height: 40px; line-height: 40px; font-size: 16px; font-weight: 700 text-align : center; color: #4A5056; border-bottom: 1px solid #C8C8C8; border-left: 1px solid #ccc; position: relative; overflow: hidden; cursor: pointer; text-align: center; } .calGrid table td img { position: absolute; left: 0; top: 0; display: none } .calGrid table td.curr img { display: block } .calGrid table td.disable { color: #ED5565; } .calGrid table td:first-child { border-left: none; } .calGrid table tr:last-child td { border-bottom: none; } .calGrid table td.holiday { font-size: 12px; } .calGrid table th.week_day, .calGrid table td.week_day { color: #ED5565 } .calGrid table td.curr { line-height: 25px; font-size: 13px; color: #fff; background: #ff6f7e; -moz-box-shadow: 2px #7d92a7 inset; -webkit-box-shadow: 2px #7d92a7 inset; box-shadow: 2px #7d92a7 dcdeeb; } .calGrid table td.curr span { display: block; font-size: 12px; line-height: 10px; } .low_calendar h1 .ldate { width: 25px; height: 25px; background: url(images/ldate.png) no-repeat; float: left; position: absolute; top: 2px; left: 10px; overflow: hidden; text-indent: -99999px } .low_calendar h1 .rdate { width: 25px; height: 25px; background: url(images/rdate.png) no-repeat; float: right; position: absolute; top: 2px; right: 10px; overflow: hidden; text-indent: -99999px } </style> <script type="text/javascript" src="js/jquery.js"></script> </head> <body> <?php /** * User: yuluo * Date: 2015-05-08 * Time: 下午3:08 * Desc:实现生成指定月份的日历信息 在此基础上可以无限遐想和扩展... */ date_default_timezone_set("Asia/Shanghai"); $time_now = time(); //strtotime("2015-02-04"); if($_REQUEST["date"]){ $time_now = strtotime($_REQUEST["date"]); } function getCurMonthFirstDay($date) { return date('Y-m-01', strtotime($date)); } function getCurMonthLastDay($date) { return date('Y-m-d', strtotime(date('Y-m-01', strtotime($date)) . ' +1 month -1 day')); } $current_y = date("Y", $time_now); $current_m = date("m", $time_now); $next_m = date('Ymd', strtotime(date('Y-m-01', $time_now) . ' +1 month')); $pre_m = date('Ymd', strtotime(date('Y-m-01', $time_now) . ' -1 month')); ?> <p class="rili"> <p class="chosedate"> <p class="low_calendar"> <h1><a class="ldate" href="date_ctrl.php?date=<?php echo($pre_m); ?>">上一月</a><span><?php echo($current_y); ?>年<?php echo($current_m); ?>月</span><a class="rdate" href="date_ctrl.php?date=<?php echo($next_m); ?>">下一月</a></h1> <p class="calGrid"> <table cellspacing="1" cellpadding="1"> <tbody> <tr> <th class="week_day">周日</th> <th>周一</th> <th>周二</th> <th>周三</th> <th>周四</th> <th>周五</th> <th class="week_day">周六</th> </tr> <?php //$time_now = strtotime("2015-05-11"); $str_time_now = date("Y-m-d", $time_now); ////////字符串格式的当前时间 $current_month_first_day = getCurMonthFirstDay($str_time_now); /////////当前月的第一天 $current_month_first_w_val = intval(date("w", strtotime($current_month_first_day))); //////当前月第一天是一周的第几天 周日(0)是第一天 $current_month_last_day = getCurMonthLastDay($str_time_now); ////////当前月的最后一天 $current_week_val = date("w", $time_now); $current_day_val = date("j", $time_now); $last_day_val = date("j", strtotime($current_month_last_day)); ////////当前月最后一天的天索引 $strart_time = false; $int_day_val = 1; $ctrl_step = $last_day_val + $current_month_first_w_val; ////////控件结束的位置索引 for ($i = 0; $i < 42; $i++) { if($i == 0){ ?> <tr> <?php } if ($i == $current_month_first_w_val) { $strart_time = true; } if ($i >= $ctrl_step) { $strart_time = false; } if ($strart_time) { $tem_current_date = date("Y-m-d",strtotime(date("Y-m", $time_now).("-").strval($int_day_val))); $str_td_class = ""; if (($i%7)==0 || (($i + 1) % 7) == 0){ $str_td_class = "week_day"; } ?> <td date="<?php echo($tem_current_date); ?>" class="<?php echo($str_td_class); ?>"><?php echo($int_day_val); ?></td> <?php $int_day_val++; } else { ?> <td class="null"> </td> <?php } if ((($i + 1) % 7) == 0) { ?> </tr> <?php } } ?> </tbody> </table> </p> </p> </p> </p> <script type="text/javascript"> $(function(){ console.log($("td [date='2015-05-12']")); }); </script> </body> </html>

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

Atom编辑器mac版下载
最流行的的开源编辑器

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

Dreamweaver CS6
视觉化网页开发工具