php 获取农历,PHP获取农历、阳历转阴历

PHP获取农历、阳历转阴历

4433405c0f9a0ab314a5f145b4d6470c.png<?php

class lunar{

#农历每月的天数

var $everyCMonth=array(

0=>array(8,0,0,0,0,0,0,0,0,0,0,0,29,30,7,1),

1=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,8,2),

2=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,9,3),

3=>array(5,29,30,29,30,29,29,30,29,29,30,30,29,30,10,4),

4=>array(0,30,30,29,30,29,29,30,29,29,30,30,29,0,1,5),

5=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,2,6),

6=>array(4,29,30,30,29,30,29,30,29,30,29,30,29,30,3,7),

7=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,4,8),

8=>array(0,30,29,29,30,30,29,30,29,30,30,29,30,0,5,9),

9=>array(2,29,30,29,29,30,29,30,29,30,30,30,29,30,6,10),

10=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,7,11),

11=>array(6,30,29,30,29,29,30,29,29,30,30,29,30,30,8,12),

12=>array(0,30,29,30,29,29,30,29,29,30,30,29,30,0,9,1),

13=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,10,2),

14=>array(5,30,30,29,30,29,30,29,30,29,30,29,29,30,1,3),

15=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,2,4),

16=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,3,5),

17=>array(2,30,29,29,30,29,30,30,29,30,30,29,30,29,4,6),

18=>array(0,30,29,29,30,29,30,29,30,30,29,30,30,0,5,7),

19=>array(7,29,30,29,29,30,29,29,30,30,29,30,30,30,6,8),

20=>array(0,29,30,29,29,30,29,29,30,30,29,30,30,0,7,9),

21=>array(0,30,29,30,29,29,30,29,29,30,29,30,30,0,8,10),

22=>array(5,30,29,30,30,29,29,30,29,29,30,29,30,30,9,11),

23=>array(0,29,30,30,29,30,29,30,29,29,30,29,30,0,10,12),

24=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,1,1),

25=>array(4,30,29,30,29,30,30,29,30,30,29,30,29,30,2,2),

26=>array(0,29,29,30,29,30,29,30,30,29,30,30,29,0,3,3),

27=>array(0,30,29,29,30,29,30,29,30,29,30,30,30,0,4,4),

28=>array(2,29,30,29,29,30,29,29,30,29,30,30,30,30,5,5),

29=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,6,6),

30=>array(6,29,30,30,29,29,30,29,29,30,29,30,30,29,7,7),

31=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,8,8),

32=>array(0,30,30,30,29,30,29,30,29,29,30,29,30,0,9,9),

33=>array(5,29,30,30,29,30,30,29,30,29,30,29,29,30,10,10),

34=>array(0,29,30,29,30,30,29,30,29,30,30,29,30,0,1,11),

35=>array(0,29,29,30,29,30,29,30,30,29,30,30,29,0,2,12),

36=>array(3,30,29,29,30,29,29,30,30,29,30,30,30,29,3,1),

37=>array(0,30,29,29,30,29,29,30,29,30,30,30,29,0,4,2),

38=>array(7,30,30,29,29,30,29,29,30,29,30,30,29,30,5,3),

39=>array(0,30,30,29,29,30,29,29,30,29,30,29,30,0,6,4),

40=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,7,5),

41=>array(6,30,30,29,30,30,29,30,29,29,30,29,30,29,8,6),

42=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,9,7),

43=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,10,8),

44=>array(4,30,29,30,29,30,29,30,29,30,30,29,30,30,1,9),

45=>array(0,29,29,30,29,29,30,29,30,30,30,29,30,0,2,10),

46=>array(0,30,29,29,30,29,29,30,29,30,30,29,30,0,3,11),

47=>array(2,30,30,29,29,30,29,29,30,29,30,29,30,30,4,12),

48=>array(0,30,29,30,29,30,29,29,30,29,30,29,30,0,5,1),

49=>array(7,30,29,30,30,29,30,29,29,30,29,30,29,30,6,2),

50=>array(0,29,30,30,29,30,30,29,29,30,29,30,29,0,7,3),

51=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,8,4),

52=>array(5,29,30,29,30,29,30,29,30,30,29,30,29,30,9,5),

53=>array(0,29,30,29,29,30,30,29,30,30,29,30,29,0,10,6),

54=>array(0,30,29,30,29,29,30,29,30,30,29,30,30,0,1,7),

55=>array(3,29,30,29,30,29,29,30,29,30,29,30,30,30,2,8),

56=>array(0,29,30,29,30,29,29,30,29,30,29,30,30,0,3,9),

57=>array(8,30,29,30,29,30,29,29,30,29,30,29,30,29,4,10),

58=>array(0,30,30,30,29,30,29,29,30,29,30,29,30,0,5,11),

59=>array(0,29,30,30,29,30,29,30,29,30,29,30,29,0,6,12),

60=>array(6,30,29,30,29,30,30,29,30,29,30,29,30,29,7,1),

61=>array(0,30,29,30,29,30,29,30,30,29,30,29,30,0,8,2),

62=>array(0,29,30,29,29,30,29,30,30,29,30,30,29,0,9,3),

63=>array(4,30,29,30,29,29,30,29,30,29,30,30,30,29,10,4),

64=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,1,5),

65=>array(0,29,30,29,30,29,29,30,29,29,30,30,29,0,2,6),

66=>array(3,30,30,30,29,30,29,29,30,29,29,30,30,29,3,7),

67=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,4,8),

68=>array(7,29,30,29,30,30,29,30,29,30,29,30,29,30,5,9),

69=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,6,10),

70=>array(0,30,29,29,30,29,30,30,29,30,30,29,30,0,7,11),

71=>array(5,29,30,29,29,30,29,30,29,30,30,30,29,30,8,12),

72=>array(0,29,30,29,29,30,29,30,29,30,30,29,30,0,9,1),

73=>array(0,30,29,30,29,29,30,29,29,30,30,29,30,0,10,2),

74=>array(4,30,30,29,30,29,29,30,29,29,30,30,29,30,1,3),

75=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,2,4),

76=>array(8,30,30,29,30,29,30,29,30,29,29,30,29,30,3,5),

77=>array(0,30,29,30,30,29,30,29,30,29,30,29,29,0,4,6),

78=>array(0,30,29,30,30,29,30,30,29,30,29,30,29,0,5,7),

79=>array(6,30,29,29,30,29,30,30,29,30,30,29,30,29,6,8),

80=>array(0,30,29,29,30,29,30,29,30,30,29,30,30,0,7,9),

81=>array(0,29,30,29,29,30,29,29,30,30,29,30,30,0,8,10),

82=>array(4,30,29,30,29,29,30,29,29,30,29,30,30,30,9,11),

83=>array(0,30,29,30,29,29,30,29,29,30,29,30,30,0,10,12),

84=>array(10,30,29,30,30,29,29,30,29,29,30,29,30,30,1,1),

85=>array(0,29,30,30,29,30,29,30,29,29,30,29,30,0,2,2),

86=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,3,3),

87=>array(6,30,29,30,29,30,30,29,30,30,29,30,29,29,4,4),

88=>array(0,30,29,30,29,30,29,30,30,29,30,30,29,0,5,5),

89=>array(0,30,29,29,30,29,29,30,30,29,30,30,30,0,6,6),

90=>array(5,29,30,29,29,30,29,29,30,29,30,30,30,30,7,7),

91=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,8,8),

92=>array(0,29,30,30,29,29,30,29,29,30,29,30,30,0,9,9),

93=>array(3,29,30,30,29,30,29,30,29,29,30,29,30,29,10,10),

94=>array(0,30,30,30,29,30,29,30,29,29,30,29,30,0,1,11),

95=>array(8,29,30,30,29,30,29,30,30,29,29,30,29,30,2,12),

96=>array(0,29,30,29,30,30,29,30,29,30,30,29,29,0,3,1),

97=>array(0,30,29,30,29,30,29,30,30,29,30,30,29,0,4,2),

98=>array(5,30,29,29,30,29,29,30,30,29,30,30,29,30,5,3),

99=>array(0,30,29,29,30,29,29,30,29,30,30,30,29,0,6,4),

100=>array(0,30,30,29,29,30,29,29,30,29,30,30,29,0,7,5),

101=>array(4,30,30,29,30,29,30,29,29,30,29,30,29,30,8,6),

102=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,9,7),

103=>array(0,30,30,29,30,30,29,30,29,29,30,29,30,0,10,8),

104=>array(2,29,30,29,30,30,29,30,29,30,29,30,29,30,1,9),

105=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,2,10),

106=>array(7,30,29,30,29,30,29,30,29,30,30,29,30,30,3,11),

107=>array(0,29,29,30,29,29,30,29,30,30,30,29,30,0,4,12),

108=>array(0,30,29,29,30,29,29,30,29,30,30,29,30,0,5,1),

109=>array(5,30,30,29,29,30,29,29,30,29,30,29,30,30,6,2),

110=>array(0,30,29,30,29,30,29,29,30,29,30,29,30,0,7,3),

111=>array(0,30,29,30,30,29,30,29,29,30,29,30,29,0,8,4),

112=>array(4,30,29,30,30,29,30,29,30,29,30,29,30,29,9,5),

113=>array(0,30,29,30,29,30,30,29,30,29,30,29,30,0,10,6),

114=>array(9,29,30,29,30,29,30,29,30,30,29,30,29,30,1,7),

115=>array(0,29,30,29,29,30,29,30,30,30,29,30,29,0,2,8),

116=>array(0,30,29,30,29,29,30,29,30,30,29,30,30,0,3,9),

117=>array(6,29,30,29,30,29,29,30,29,30,29,30,30,30,4,10),

118=>array(0,29,30,29,30,29,29,30,29,30,29,30,30,0,5,11),

119=>array(0,30,29,30,29,30,29,29,30,29,29,30,30,0,6,12),

120=>array(4,29,30,30,30,29,30,29,29,30,29,30,29,30,7,1)

);

##############################

#农历天干

var $mten=array("null","甲","乙","丙","丁","戊","己","庚","辛","壬","癸"); #农历地支

var $mtwelve=array("null","子(鼠)","丑(牛)","寅(虎)","卯(兔)","辰(龙)",

"巳(蛇)","午(马)","未(羊)","申(猴)","酉(鸡)","戌(狗)","亥(猪)"); #农历月份

var $mmonth=array("闰","正","二","三","四","五","六",

"七","八","九","十","十一","十二","月");

var $mday=array("null","初一","初二","初三","初四","初五","初六","初七","初八","初九","初十",

"十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",

"廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十");#农历日

var $mweek=array(0=>"星期日",1=>"星期一",2=>"星期二",3=>"星期三",4=>"星期四",5=>"星期五",6=>"星期六");

##############################

#赋给初值

#天干地支

var $ten=0;

var $twelve=0;

function MyPub($cYear,$cMonth,$cDay){

$total=11;#阳历总天数 至1900年12月21日

$mtotal=0;#阴历总天数

for ($y=1901;$y

{

$total+=365;

if ($y%4==0) $total ++;

}

#再加当年的几个月

switch ($cMonth){

case 12:

$total+=30;

case 11:

$total+=31;

case 10:

$total+=30;

case 9:

$total+=31;

case 8:

$total+=31;

case 7:

$total+=30;

case 6:

$total+=31;

case 5:

$total+=30;

case 4:

$total+=31;

case 3:

$total+=28;

case 2:

$total+=31;

}

#如果当年是闰年还要加一天

if ($cYear%4==0 and $cMonth>2){

$total++;

}

$total+=$cDay-1;

##############################

#用农历的天数累加来判断是否超过阳历的天数

for($j=0;$j<=120;$j++){

$i=1;

for($i=1;$i<=13;$i++)

{

$mtotal+=$this->everyCMonth[$j][$i];

if ($mtotal>=$total)

{

$flag=1;

break;

}

}

if ($flag==1)break;

}

return array("m"=>$j,"d"=>$i,"t"=>$total,"n"=>$mtotal);

}

function Cal($Year,$Month,$Day){

$Par=$this->MyPub($Year,$Month,$Day);

$md=$this->everyCMonth[$Par["m"]][$Par["d"]]-($Par["n"]-$Par["t"]);

$week=($Par["t"]+5)%7;

$week=$this->mweek[$week];//转中文星期

if ($this->everyCMonth[$Par["m"]][0]<>0 and $this->everyCMonth[$Par["m"]][0]

$mm=$Par["d"]-1;

}else{

$mm=$Par["d"];

}

if ($Par["d"]==$this->everyCMonth[$Par["d"]][0]+1 and $this->everyCMonth[$Par["d"]][0]<>0){

$cMonth=$this->mmonth[0].$this->mmonth[$mm];#闰月

}else{

$cMonth=$this->mmonth[$mm].$this->mmonth[13];

}

return array("year"=>$this->mten[$this->everyCMonth[$Par["m"]][14]].$this->mtwelve[$this->everyCMonth[$Par["m"]][15]],

"month"=>$cMonth,

"day"=>$this->mday[$md],

"week"=>$week);

}

}

/***************************************调用***************************************/

$lunar=new lunar();

$nowday=$lunar->Cal(date("Y"),date("m"),date("d"));

echo date("Y年m月d日")." ".$nowday["week"].'
农历'.$nowday["year"]."年".$nowday["month"].$nowday["day"]."日 ";

?>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/57035.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【微信小程序】农历公历互相转换

文章目录 需求来源实战代码核心方法运行效果工具方法 其他优化 需求来源 之前写了一篇获取农历日期的文章&#xff0c;【微信小程序】获取农历及星期&#xff0c;后来想到我这个小程序【TimeAssistant】中的“远离工作”功能模块还得优化&#xff0c;具体功能界面如下图 此功能…

阳历转换成阴历PHP实现详解

结合上次做的日历&#xff0c;提前粘贴一下效果图 当前月份 下一个月 相关概念 阳历&#xff0c;有很强的规律性。每年12个月&#xff0c;1、3、5、7、8、10、12月都为31天&#xff1b;平年2月份28天&#xff0c;润年2月份29天&#xff0c;其余的月30天。 阴历&#x…

c语言中万年历公历农历转换,公历农历转换,教你切换阳历和阴历生日

公历&#xff0c;又叫阳历&#xff0c;农历&#xff0c;又叫阴历&#xff0c;阳历和阴历所依据的参照物不同&#xff0c;计算方法也不一样&#xff0c;应该如何换算呢&#xff1f;下面就来看看本文关于公历农历转换&#xff0c;教你切换阳历和阴历生日的分析吧。 一、快速切换方…

阳历转阴历,阳历转中国农历

文章目录 阳历转阴历&#xff0c;阳历转中国农历 阳历转阴历&#xff0c;阳历转中国农历 阳历转阴历一直都是很繁琐的过程&#xff0c;所以我制作了一个开发包&#xff0c;来方便我们转换阳历到中国农历。 让我们下载 moon-time&#xff1a; moon-time 是一个将阳历转换为阴…

软件设计师---结构化开发

笔记有错误欢迎直接在评论区进行纠正&#xff01;我将不再维护软件设计师笔记&#xff01; 结构化开发上午题大概4分 模块化 耦合 真题 真题1 真题2 这里不要一看到数据结构就觉得是标记耦合&#xff0c;标记耦合是两个模块传递的是数据结构&#xff0c;而这里没有传递&…

软件工程之结构化方法

结构化方法 结构化分析结构化分析模型数据流图 结构化分析过程需求规格说明书需求验证 结构化设计总体设计体系结构设计接口设计数据设计 详细设计详细设计工具 软件设计规约 结构化分析 结构化方法是一种特定的软件开发方法学。 结构化方法就软件需求分析而言&#xff0c;即…

实验一 结构化分析(软件工程)

&#xff08;一&#xff09;实验目的要求 1. 了解Visio/在线绘图工具的功能特色 2. 了解Visio/在线绘图工具的工具环境 3. 运用Visio/在线绘图工具绘制数据流图 4. 能够运用Visio/在线绘图工具绘制系统E-R图 &#xff08;二&#xff09;实验材料和仪器设备 1. PC机 2. V…

【软件工程】之结构化分析

结构化分析 6.1引言6.2结构化分析建模6.3面向数据流的建模方法6.4面向数据的建模方法6.5面向状态的建模方法6.6思考题1、结构化分析的特点2、数据流图的建模元素3、数据字典 结构化需求分析的建模方法&#xff1a; ①面向数据流的建模方法&#xff1a; 数据流图(DFD)-功能域 ②…

系分 - 结构化方法【概念】

个人总结&#xff0c;仅供参考&#xff0c;欢迎加好友一起讨论 文章目录 系分 - &#xff08;概念&#xff09;结构化方法结构化分析&#xff08;SA&#xff0c;Structured Analysis&#xff09;结构化设计&#xff08;SD&#xff0c;Structured Design&#xff09;结构化程序设…

软件工程——结构化分析

目录 一、结构化分析方法 二、功能建模 三、数据建模 四、行为建模 五、数据字典 六、加工规格说明 一、结构化分析方法 传统的分析建模方法称为结构化分析&#xff08;structured analysis&#xff0c;SA&#xff09;方法。 最有代表性的是一种面向数据流进行需求分析的方…

GPT-4“王炸”发布!1秒生成网站!

果然&#xff0c;能打败昨天的OpenAI的&#xff0c;只有今天的OpenAI。 刚刚&#xff0c;OpenAI震撼发布了大型多模态模型GPT-4&#xff0c;支持图像和文本的输入&#xff0c;并生成文本结果。 OpenAI老板Sam Altman直接开门见山地介绍说&#xff1a; 这是我们迄今为止功能最强…

StackLLaMA: 用 RLHF 训练 LLaMA 的手把手教程

来自&#xff1a;Hugging Face 进NLP群—>加入NLP交流群 如 ChatGPT&#xff0c;GPT-4&#xff0c;Claude 这样的语言模型之所以强大&#xff0c;是因为它们采用了 基于人类反馈的强化学习 (Reinforcement Learning from Human Feedback, RLHF) 来使之更符合我们的使用场景。…

ChatGPT 已能操控机器人,工程师连代码都不用写,网友:微软在搞天网?

Alex 发自 凹非寺 本文源自&#xff1a;量子位 | 公众号 QbitAI 当我还在跟ChatGPT吹牛尬聊时&#xff0c;有人已经在拿它操控机器人了。 不是别人&#xff0c;正是OpenAI的金主爸爸、不久前刚拿ChatGPT“重新发明搜索引擎”的微软。 到目前为止&#xff0c;开发者调教机器人…

自从使用了Cursor工作效率飞起

什么是Cursor 官网&#xff1a;https://www.cursor.so/ 看官网接受大家应该就知道是什么东西了&#xff0c;他是一个开源的AI编程编辑器。开源地址https://github.com/getcursor/cursor 目前在国内是可以不需要其他东西&#xff0c;可以之间访问的。而且目前免费使用。支持多…

大模型惨遭人类大范围攻击!国内各领域专家组团投毒,GPT-4 也 Hold 不住

这是「进击的Coder」的第 852 篇技术分享 作者&#xff1a;关注前沿科技 来源&#xff1a;量子位 “ 阅读本文大概需要 9 分钟。 ” 包括 GPT-4 在内等多个大模型惨遭人类攻击&#xff01;还是大范围、多边形那种。 而且这个军团被爆个个来头不小。 包括社会学家李银河、心理学…

宵夜杂谈 | Uni3D是自动驾驶脱不去的长衫?

作者 | matrix明仔 编辑 | 汽车人 原文链接&#xff1a;https://zhuanlan.zhihu.com/p/616531799 点击下方卡片&#xff0c;关注“自动驾驶之心”公众号 ADAS巨卷干货&#xff0c;即可获取 点击进入→自动驾驶之心【全栈算法】技术交流群 1说在前面的话 我一个朋友昨天喝了两大…

CUDA实战 | CUDA卷积算子手写详细实现流程!

作者 | Pegessi 编辑 | 极市平台 原文链接&#xff1a;https://zhuanlan.zhihu.com/p/613538649 点击下方卡片&#xff0c;关注“自动驾驶之心”公众号 ADAS巨卷干货&#xff0c;即可获取 点击进入→自动驾驶之心【模型部署】技术交流群 后台回复【CUDA】获取CUDA实战书籍&…

万字长文 | 详解CUDA卷积算子手写实现

作者 | Pegessi 编辑 | 极市平台 原文链接&#xff1a;https://zhuanlan.zhihu.com/p/613538649 点击下方卡片&#xff0c;关注“自动驾驶之心”公众号 ADAS巨卷干货&#xff0c;即可获取 点击进入→自动驾驶之心【模型部署】技术交流群 导读 本篇文章主要介绍如何利用CUDA实现…

第一次玩剧本杀,基本说明与模型抽取

本文分两部分&#xff0c;第一部分是基本说明&#xff0c;第二部分是模型抽取。 一、基本说明 根据不同剧本&#xff0c;参与人数7/-2人&#xff0c;跟Scrum的黄金人数一致。游戏时长3~5小时&#xff0c;跟两周迭代的计划会时长一致。 每个角色都有自己的剧本&#xff0c;剧本中…

巴比特 | 元宇宙每日必读:虚拟数字人是否享有著作权或邻接权?杭州互联网法院判决首例涉“虚拟数字人”侵权案...

摘要&#xff1a;据杭州互联网法院报道&#xff0c;近日&#xff0c;杭州互联网法院就首例涉“虚拟数字人”侵权案作出了一审判决。本案判决结合人工智能技术应用及虚拟数字人发展现状&#xff0c;从权利主体、客体、权利归属等多层面分析虚拟数字人在现有《著作权法》框架下不…