?
Solved

Countdown to my Birthday

Posted on 2005-04-20
7
Medium Priority
?
426 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:kevinsmith121
7 Comments
 
LVL 14

Assisted Solution

by:dfu23
dfu23 earned 200 total points
ID: 13827090
0
 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 600 total points
ID: 13827373
<script language="javascript">
<!--
var now = new Date();
var event = new Date("Dec 5 2005 00:00:01");
var seconds = (event - now) / 1000;
var minutes = seconds / 60;
var hours = minutes / 60;
var days = hours / 24;
ID=window.setTimeout("update();", 1000);
function update() {
now = new Date();
seconds = (event - now) / 1000;
seconds = Math.round(seconds);
minutes = seconds / 60;
minutes = Math.round(minutes);
hours = minutes / 60;
hours = Math.round(hours);
days = hours / 24;
days = Math.round(days);
document.write(days + " days, " + hours + " hours, " + minutes + " minutes, and " + seconds + " seconds until my Birthday!");
}
// -->
</script>
0
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 1200 total points
ID: 13829481
Put  <div id="showTime"></div>  any where you want in the page to display the count down

<script>
birth=new Date("Dec 25 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()
diff.setTime(diffTime+now.getTimezoneOffset( )*360*1000)
msg='<center><font size=5>'+(diff.getFullYear()-1970)+' years ' + diff.getMonth() + ' Months '+ diff.getDate()+' 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>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:kevinsmith121
ID: 13834722
Thankyou all
0
 
LVL 1

Author Comment

by:kevinsmith121
ID: 13834767
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
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 13836084
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>

0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 13839505
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")
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question