473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Daycount problem

Ich want to count the days between the current day an the birthday next
Year. For example (mm.dd.yyyy): Today : 07.01.2004 Birthday: 07.06.1977.
How can I calculate the days to the next birthday ??

Please help me !! Thanks Fraya Pohl
Jul 17 '05 #1
4 1600
*** Fraya Pohl wrote/escribió (1 Jul 2004 01:41:27 -0500):
Ich want to count the days between the current day an the birthday next
Year. For example (mm.dd.yyyy): Today : 07.01.2004 Birthday: 07.06.1977.
How can I calculate the days to the next birthday ??


Create timestamps and substract:

<?
echo (strtotime('2004-07-01')-strtotime('1977-07-06')) / 86400;
?>

Where 86400=60*60*24 (seconds/day)
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #2
In article <MP************************@news2.premium-news.de>,
fr***@nettaxi.com says...
Ich want to count the days between the current day an the birthday next
Year. For example (mm.dd.yyyy): Today : 07.01.2004 Birthday: 07.06.1977.
How can I calculate the days to the next birthday ??


Check out the functions date, getdate and strtotime.

// get timestamp for today
$today_tstamp = date();
// get date array data for today
$today = getdate($today_tstamp);

$bday_string = '1977-07-06';

// get timestamp for birthday
$bday_tstamp = strtotime($bday_string);
// get date array data for birthday
$bday = getdate($bday_tstamp);

// get timestamp for birthday date in this year
$bty_tstamp = strtotime($today[year].'-'.$bday[mon].'-'($bday[mday]);

if ($today_tstamp < $bty_tstamp) {
// birthday not yet happened this year
$bty = getdate($bty_tstamp);
$days_to_party = $bty[yday] - $today[yday]
} else {
// put more stuff here to get timestamp for birth date next year,
// and working out if leap year complications exist, etc.
}

Geoff M
Jul 17 '05 #3
Fraya Pohl wrote:
Ich want to count the days between the current day an the birthday
next Year. For example (mm.dd.yyyy): Today : 07.01.2004 Birthday:
07.06.1977. How can I calculate the days to the next birthday ??

Please help me !! Thanks Fraya Pohl


<script language="javascript" type="text/javascript">
//<![CDATA[
<!-- Countdown Script by Maxim V. Kollegov -->
<!-- http://www.geocities.com/siliconvalley/lakes/8620 -->
<!-- please keep this comment unchanged if you use it -->
<!-- hide script
//change your event date event here.
var eventdate = new Date("Sep 21, 2011 00:00:00");

function toSt(n)
{s=""
if(n<10) s+="0"
return s+n.toString();
}

function countdown()
{cl=document.clock;
d=new Date();
count=Math.floor((eventdate.getTime()-d.getTime())/1000);
if(count<=0)
{cl.days.value ="----";
cl.hours.value="--";
cl.mins.value="--";
cl.secs.value="--";
return;
}
cl.secs.value=toSt(count%60);
count=Math.floor(count/60);
cl.mins.value=toSt(count%60);
count=Math.floor(count/60);
cl.hours.value=toSt(count%24);
count=Math.floor(count/24);
cl.days.value=count;

setTimeout("countdown()",500);
}
// end script -->
//]]>
</script>

<body bgcolor="#E0E0E0" text="#404040" link="#FF6600" vlink=
"#808080" onload="countdown()">
<form name="clock" action="countdown" id="clock"><font face=
"Times"><b>Nog <input type="text" name="days" size="4" />dagen,
<input type="text" name="hours" size="2" />uren, <input type=
"text" name="mins" size="2" />minuten en <input type="text" name=
"secs" size="2" />seconden,<br />
dan is het 21 september 2011<br />
Die dag is het zeventig jaar geleden dat ik ben
geboren.</b></font></form>

Gerard Schaefers
--
Voor meer kook- en eetplezier? Kijk hier!
http://www.xs4all.nl/~sjeef/Nederlands/Recepten.html
Jul 17 '05 #4
>Ich want to count the days between the current day an the birthday next
Year. For example (mm.dd.yyyy): Today : 07.01.2004 Birthday: 07.06.1977.
How can I calculate the days to the next birthday ??


Using the example above, what is the correct answer?

I claim the answer is 4 (Jul 2, Jul 3, Jul 4, and Jul 5 are between
Jul 1 and Jul 6. Neither Jul 1 nor Jul 6 are between Jul 1 and Jul
6).

Some people claim the answer is 5 (obtained by subtracting).

How many days are between today and tomorrow? (I claim 0.)
How many days are between a day and itself? (It sounds stupid, but
the only answer that seems to make sense to me is -1.)

You can convert both dates to a Julian day, subtract, then subtract one.
Take a look at the functions juliantojd() or gregoriantojd(). You
may need to reconfigure PHP to include support for the calendar functions.

Gordon L. Burditt
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
9
by: Sudesh Sawant | last post by:
Hello, We have an application which communicates using remoting. There is a server which is a Windows Service. The server exposes an object which is a singleton. The client is a Web Application...
117
by: Peter Olcott | last post by:
www.halting-problem.com
17
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.