2024-08-13 07:29:57 | 我爱编程网
我爱编程网(https://www.52biancheng.com)小编还为大家带来php显示日期,周几,农历初几,什么节日函数的相关内容。
一般是用js来显示:
今天是<script language="javascript">RunGLNL();</script>
2014年12月28日 星期日 农历冬月初七
<script>function RunGLNL(){var e=new Date,t=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"),i=e.getFullYear()+"年"+[e.getMonth()+1]+"月"+e.getDate()+"日";intHours=e.getHours(),intMinutes=e.getMinutes(),intSeconds=e.getSeconds(),0==intHours?(hours="12:",xfile=""):12>intHours?(hours=intHours+":",xfile=""):12==intHours?(hours="12:",xfile=""):(intHours-=12,hours=intHours+":",xfile=""),minutes=10>intMinutes?"0"+intMinutes+":":intMinutes+":",seconds=10>intSeconds?"0"+intSeconds+" ":intSeconds+" ",i=i+" "+t[e.getDay()];var i=i+" "+CnDateofDateStr(e);i+=SolarTerm(e),document.write(i)}function DaysNumberofDate(e){return parseInt((Date.parse(e)-Date.parse(e.getFullYear()+"/1/1"))/864e5)+1}function CnDateofDate(e){var t,i,a,n,r,o,s,l,d=new Array(22,42,218,0,131,73,182,5,14,100,187,0,25,178,91,0,135,106,87,4,18,117,43,0,29,182,149,0,138,173,85,2,21,85,170,0,130,85,108,7,13,201,118,0,23,100,183,0,134,228,174,5,17,234,86,0,27,109,42,0,136,90,170,4,20,173,85,0,129,170,213,9,11,82,234,0,22,169,109,0,132,169,93,6,15,212,174,0,26,234,77,0,135,186,85,4),c=new Array,h=new Array,u=new Array,p=e.getFullYear();if(e.getMonth()+1,e.getDate(),100>p&&(p+=1900),1997>p||p>2020)return 0;for(u[0]=d[4*(p-1997)],u[1]=d[4*(p-1997)+1],u[2]=d[4*(p-1997)+2],u[3]=d[4*(p-1997)+3],c[0]=0!=(128&u[0])?12:11,t=127&u[0],n=u[1],n<<=8,n|=u[2],i=u[3],a=15;a>=0;a--)h[15-a]=29,0!=(1<<a&n)&&h[15-a]++,c[15-a]==i?c[15-a+1]=-i:(c[15-a+1]=c[15-a]<0?-c[15-a]+1:c[15-a]+1,c[15-a+1]>12&&(c[15-a+1]=1));if(r=DaysNumberofDate(e)-1,r<=h[0]-t)s=p>1901&&CnDateofDate(new Date(p-1+"/12/31"))<0?-c[0]:c[0],l=t+r;else{for(o=h[0]-t,a=1;r>o&&o+h[a]<r;)o+=h[a],a++;s=c[a],l=r-o}return s>0?100*s+l:100*s-l}function CnYearofDate(e){var t=e.getFullYear(),i=e.getMonth()+1,a=parseInt(Math.abs(CnDateofDate(e))/100);return 100>t&&(t+=1900),a>i&&t--,t-=1864,CnEra(t)+"年"}function CnMonthofDate(e){var t,i=new Array("零","正","二","三","四","五","六","七","八","九","十","冬","腊");return t=parseInt(CnDateofDate(e)/100),0>t?"闰"+i[-t]+"月":i[t]+"月"}function CnDayofDate(e){var t,i=new Array("零","初一","初二","初三","初四","初五","初六","初七","初八","初九","初十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十");return t=Math.abs(CnDateofDate(e))%100,i[t]}function DaysNumberofMonth(e){var t=e.getFullYear();100>t?t+=1900:t;var i=t;return t+="/"+(e.getMonth()+1),i+="/"+(e.getMonth()+2),t+="/1",i+="/1",parseInt((Date.parse(i)-Date.parse(t))/864e5)}function CnEra(e){var t=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸"),i=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");return t[e%10]+i[e%12]}function CnDateofDateStr(e){return"零月"==CnMonthofDate(e)?" 请调整您的计算机日期!":"农历"+CnMonthofDate(e)+CnDayofDate(e)}function SolarTerm(e){var t=new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"),i=new Array(1272060,1275495,1281180,1289445,1299225,1310355,1321560,1333035,1342770,1350855,1356420,1359045,1358580,1355055,1348695,1340040,1329630,1318455,1306935,1297380,1286865,1277730,1274550,1271556),a=31556926,n=new Date(1901);for(n.setTime(94712046e4);e.getFullYear()<n.getFullYear();)n.setTime(n.getTime()-1e3*a);for(;e.getFullYear()>n.getFullYear();)n.setTime(n.getTime()+1e3*a);for(var r=0;e.getMonth()>n.getMonth();r++)n.setTime(n.getTime()+1e3*i[r]);e.getDate()>n.getDate()&&(n.setTime(n.getTime()+1e3*i[r]),r++),e.getDate()>n.getDate()&&(n.setTime(n.getTime()+1e3*i[r]),23==r?r=0:r++);var o="";return e.getDate()==n.getDate()&&(o+=" <i>"+t[r]+"</i>"),o}</script>以上就是我爱编程网小编给大家带来的php日历模块的运算逻辑求解!如何求日期对应的星期几!,希望能对大家有所帮助。更多相关文章关注我爱编程网:www.52biancheng.com
求教PHP:数据读取、日期计算以及生成图片你的数据字段是date类型吧,应该使用mysql的datediff函数,可以直接获取天数,在我的数据库里面执行下面语句:selectuser,regtime,datediff(now(),regtime)fromweb.clubuserlimit10的结果为:userregtimedatediff(now(),regtime)英子20
PHP计算一年多少个星期和每周的开始和结束日期PHP计算一年多少个星期和每周的开始和结束日期?方法如下:方法一:<phpheader("Content-type:text/html;charset=utf-8");date_default_timezone_set("Asia/Shanghai");$year=(int)$_GET['year'];$week=(
PHP日期加减计算方法示例探讨PHP中日期加减计算的多种方法及其应用实例。首先,PHP提供了标准的日期格式函数date("Y-m-dH:i:s");,用于输出日期和时间。接着,简单的日期加减计算可以通过直接在日期字符串上进行加减操作实现。例如,将当前日期"2017-11-0618:58:04"加上一天,结果为"2017-11-0718:58:04"。对于更进阶的日期加减操作
phpstrptime定义和用法PHP中的strptime()函数是一个关键工具,用于解析由strftime()生成的日期/时间格式。它的主要任务是将一个字符串按照特定的格式进行解析,以便于后续的处理和存储。strptime()函数的基本语法如下:arraystrptime(date,format)其中,参数date是需要解析的字符串,通常来源于strftime()
php中的以下函数:1.mktime()2.time()3.date()4.getdate()5.strtotime()MkTime函数描述:intmktime(inthour,intminute,intsecond,intmonth,intday,intyear);返回值:函数mktime返回给出日期的时间戳,即从1970年1月1日开始的秒数。所有参数都可选,若为空,则使用当前值。
PHP数组计算如下数组$arr,求方法随机对数组的值相加,求和为指定值:如(690),输出:405+180+105=690<?php$arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];/** * 根据某个值对数组中的元素进行分组 */function getGroupBySum($arr, $sum) { $len = count($arr); $resu
php时间time与日期date之间的使用详解及区别php时间time与日期date之间的使用区别1、time()函数PHP中的time()函数,使用echo输出来看是一个很长的整数,里面包含了日期和时间,是计算后的一个值。如果要得到Y-m-dH:i:s这样的日期格式,那么可以使用date方法:date('Y-m-dH:i:s',time());echo输出它即可
PHP中用日期函数显示当前年月日喝当前时间在PHP中,使用日期函数可以方便地显示当前年月日和时间。例如:echodate("Y-m-dH:i:s",time());可以输出当前的日期和时间,这里的time()函数返回的是自1970年1月1日00:00:00GMT以来的秒数。如果您想要显示的是格林尼治时间元年的日期和时间,可以使用echodate("Y-m-dH:i:s",0);,这里的0表示
2025-02-01 20:24:39
2025-02-12 03:21:37
2025-02-10 15:19:48
2025-01-28 17:58:32
2024-11-22 05:08:01
2024-09-10 08:50:00