Link to home
Start Free TrialLog in
Avatar of kevinsmith121
kevinsmith121

asked on

Countdown to my Birthday

Dear all,

I am developing a website that I hope to launch on my 30th Birthday, this is in a few weeks, on the homepage I would like to display a neat digital countdown to my birthday 12/05/2005. The site is going to be dedicated to life during my 30's so it is quite significant, also after I turn 30 it would be cool to display how long I have been in my 30's for. If you are interested the site is www.30somethinggamer.com, there is no content on the site at the moment at all it is just an empty shell, any advice would be most appreciated

Many thanks

Kevin
SOLUTION
Avatar of dfu23
dfu23

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevinsmith121
kevinsmith121

ASKER

Thankyou all
This is an excellent set of answers with GwynforWeb's being the best, I have implimented, upped the points and awarded accordingly

many thanks

Kevin
thx for the points, this is better. There is still a problem with daylight savings which I will look into.

<script>
birth=new Date("Apr 22 2005 00:00:01")

function showDiff(){
now=new Date()
diffTime=now.getTime()-birth.getTime()
if (diffTime > 0)
  msg="<p>Since my 30th birthday"
else{
  msg="<p>To my 30th birthday"
  diffTime=-diffTime
}

diff=new Date(diffTime+now.getTimezoneOffset( )*60*1000)

msg='<center><font size=5>'+(diff.getFullYear()-1970)+' years ' + diff.getMonth() + ' Months '+ (diff.getDate()-1)+' days ' + diff.getHours()+' hours '  + diff.getMinutes()+' minutes '+ diff.getSeconds()+' seconds' +msg+'</font></center>'
document.getElementById("showTime").innerHTML=msg

}
</script>


<body onload="showDiff();setInterval('showDiff()',1000)">
  <div id="showTime"></div>
</body>
</html>

ah ha, I have got it exact at last, change to the birthday to hour 1

birth=new Date("Apr 22 2005 01:00:00")