生日祝福的代码,时间搞不懂~~谢谢帮忙~

Python014

生日祝福的代码,时间搞不懂~~谢谢帮忙~,第1张

问题是:例如A的生日是今天,B的生日是明天,结果昨天中午12点起到今天上午12点前就显示是A的生日,过了中午12点就显示为B的生日了。时间上挪了12小时,也就是它是以中午12点为转换点,而不是晚上12点为转换点。。求助!谢谢!!!代码如下

<body BGCOLOR="#DEDEDE" TEXT="#000000" oncontextmenu=self.event.returnValue=false>

<div align="center"><FONT COLOR=red FACE=隶书 SIZE=6>

<SCRIPT LANGUAGE="JavaScript">

function birthday(year,month,date,person) {

this.year=year

this.month=month

this.date=date

this.person=person

}

function birthdaylist() {

}

blist=new birthdaylist()

blist[86]= new birthday(1980,10,24,"朋友名字")

blist[86]= new birthday(1980,6,4,"小明")

//以上加如你的朋友生日列表,格式如上

var now=new Date()

today=new Date(now.getYear(),now.getMonth(),now.getDate()) // today 0:00:00

function daysFromToday(sdate) {

return Math.round((sdate.getTime()-today.getTime())/(24*60*60*1000))

}

function writeNextBirthday(list) {

var daysToClosest=888

var closest

for (var i in list) {

thisDate=new Date(today.getYear(),list[i].month-1,list[i].date)

if (daysFromToday(thisDate)<0)

thisDate.setYear(today.getYear()+1)

if (daysFromToday(thisDate)<daysToClosest) {

daysToClosest=daysFromToday(thisDate)

closest=i

}

}

if (daysToClosest==0)

// document.write("<B>今天["+list[closest].person+"]"+"["+(today.getYear()-list[closest].year)+"]岁大寿!祝你生日快乐^0^</B>")

document.write("<B><FONT COLOR=red >今天是["+list[closest].person+"]"+"的生日!祝你生日快乐</B>")

else if (daysToClosest==1)

document.write("<FONT COLOR=blue >明天是["+list[closest].person+"]的生日!大家不要忘了~")

else

document.write("[<font color=red>"+list[closest].person+"]</font>将在["+daysToClosest+"]天后过生日")

}

</SCRIPT>

</FONT></div>

<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BORDERCOLORDARK="#FFFFFF" BORDERCOLOR="#000000" ALIGN="CENTER">

<TR BGCOLOR="#CCFFCC"><TD bgcolor="#DFDFDF"><DIV ALIGN="center"><FONT COLOR=red SIZE="5"><strong>会 员 生 日 榜</strong></FONT></DIV>

<DIV ALIGN="CENTER"><SCRIPT LANGUAGE=JavaScript>

today=new Date()

function initArray(){

this.length=initArray.arguments.length

for(var i=0i<this.lengthi++)

this[i+1]=initArray.arguments[i] }

var d=new initArray(

"星期日",

"星期一",

"星期二",

"星期三",

"星期四",

"星期五",

"星期六")

document.write(

"<font color=##000000 style='font-size:9ptfont-family: 宋体'>",

today.getYear(),"年",

today.getMonth()+1,"月",

today.getDate(),"日",

d[today.getDay()+1],

"</font>" )

</SCRIPT>

</DIV></TD></TR><TR><TD bgcolor="#DFDFDF"><DIV ALIGN="center">

<SCRIPT LANGUAGE=JavaScript>

<!--

writeNextBirthday(blist)

// -->

</SCRIPT></DIV></TD></TR></TABLE>

你再贴这么多代码,我就费了你

前几天一个朋友找到我,他说他女朋友马上过生日,于是想问问我能不能写一个生日祝福代码。好兄弟的请求当然不能拒绝,直接安排!!

于是我用html写了一个简单的页面:点开后会显示来到这个世界多长时间和祝福话语,下滑后是自转相册(有背景音乐)。

原文链接:

html生日快乐代码

核心代码(不是完整代码):

#head

{

width:100%

height:100%

position: absolute

-webkit-transform-style: preserve-3d

-webkit-animation:donghua 15s linear 0s infinite

-moz-transform-style: preserve-3d

-moz-animation:donghua 15s linear 0s infinite

-ms-transform-style: preserve-3d

-ms-animation:donghua 25s linear 0s infinite

}

#head div

{

position: absolute

top:0

left:0

width:300px

height:400px

border:1px solid #000

text-align: center

line-height:100px

}

#head div:nth-child(1)

{

-webkit-transform:rotateY(0deg) translateZ(400px)

-moz-transform:rotateY(0deg) translateZ(400px)

-ms-transform:rotateY(0deg) translateZ(400px)

background:url(images/01.png)

background-size:cover

}12345678910111213141516171819202122232425262728293031

Heart.prototype.draw = function(){

this.size -= this.speedSize

this.x += this.speedX

this.y += this.speedY

ctx.save()

ctx.translate(-1000,this.y)

ctx.scale(this.size, this.size)

ctx.beginPath()

for (var i = 0i <precisioni++) {

var vector = this.vertices[i]

ctx.lineTo(vector.x, vector.y)

}

ctx.globalAlpha = this.size

ctx.shadowBlur = Math.round((3 - this.size) * 10)

ctx.shadowColor = "hsla(0, 100%, 60%,0.5)"

ctx.shadowOffsetX = this.x + 1000

ctx.globalCompositeOperation = "screen"

ctx.closePath()

ctx.fill()

ctx.restore()

}

function render(a){

requestAnimationFrame(render)

hearts.push(new Heart())

ctx.clearRect(0,0,ww,wh)

for (var i = 0i <hearts.lengthi++) {

hearts[i].draw()

if(hearts[i].size <= 0){

hearts.splice(i,1)

i--

}

}

}

onResize()

window.addEventListener("mousemove", onMove)

window.addEventListener("touchmove", onMove)

window.addEventListener("resize", onResize)

requestAnimationFrame(render)

window.οnlοad=function starttime(){

time(h1,'2000,1,1')    // 出生时间

ptimer = setTimeout(starttime,1000)// 添加计时器

}

function time(obj,futimg){

var nowtime = new Date().getTime()// 现在时间转换为时间戳

var futruetime =  new Date(futimg).getTime()// 未来时间转换为时间戳

var msec = nowtime-futruetime// 毫秒 未来时间-现在时间

var time = (msec/1000) // 毫秒/1000

var day = parseInt(time/86400)// 天  24*60*60*1000

var hour = parseInt(time/3600)-24*day   // 小时 60*60 总小时数-过去的小时数=现在的小时数

var minute = parseInt(time%3600/60)// 分 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数

var second = parseInt(time%60) // 以60秒为一整份 取余 剩下秒数

obj.innerHTML="陈陈<br>你已经来到这个世界:<br>"+day+"天"+hour+"小时"+minute+"分"+second+"秒"+"了<br><span>今日是你的生日,愿所有的快乐、所有的幸福、所有的温馨、所有的好运围绕在你身边。生日快乐!</span><p>下<br>滑<br>有<br>惊<br>喜</p>"

return true

}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162

效果如下:

这里面的文字可以自行修改,并且时间是会一直走动的,出生时间改成你女朋友的。

下滑后有自转照片:

照片可以自己换哦。

补充:

很多朋友想手机端打开文件,那就需要换图片的地址和音频的地址(你可以发一个仅自己可见的说说,然后就可以生成图片的链接地址了),此时只需要发html文件就可以用手机浏览器打开了。

上图的地址换成图片的链接网址(一共十个)。

对于音频文件,我这里提供一个链接(可能过期):https://www.0dutv.com/upload/dance/20200305/D1E8DB5EB16A57732BDD636C759DA034.mp3

上图的地址换成音频的链接网址。

大家可以网上找音乐外链。

如果是特定的音频录音,可以用这个方法:利用邮箱附件的形式,比如QQ邮箱,给自己发一封邮件,把音乐以附件的形式附带在上面,收信的时候用来下载附件的那个地址,就是歌曲的下载链接了。

完整项目:

里面有我自己找的十张照片和两个背景音乐(可以换成自己的录音),另外还有使用说明。

完整项目地址:html生日快乐代码

编写一个简单的生日快乐APP

一、关闭之前的helloworld程序

点击file,然后close project,就完成关闭了。

二、创建一个新的happybirthday程序

三、下面开始整个APP的修改

1、如何查看Androidstudio中activity_main.xml的源代码,在图中 灰色部分现在是Design,点到code就会出现activity_main_xml的代码了。

2、进行如下代码的修改。把根布局改成相对布局 androidx.constraintlayout.widget.ConstraintLayout改为RelativeLayout

把多余的代码删除掉 ,并将文本内容改为android:text="祝你生日快乐!"

app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"

并可以修改文字的大小,颜色,添加边框.。代码如下:

3、在左侧目录下,res是存放资源文件的(图片放进来);java是存放java代码的;mainfests是存放配置文件的。因此将图片复制在最侧res目录下。

4、将代码补充完整

代码:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

<TextView

android:layout_margin="20dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="祝你生日快乐!"

android:textColor="@android:color/holo_orange_light"

android:textSize="22dp"

/>

<ImageView

android:layout_centerInParent="true"

android:src="@drawable/img"

android:layout_width="match_parent"

android:layout_height="wrap_content" />

</RelativeLayout>

5、最后的效果如图所示

6、可在手机中看到happybirthday的程序包,打开便是上面的画面。