Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Calculate Age Based On Date Of Birth


I am trying to validate whether or not a date of birth entered in dd/mm/yyyy format is between 16 and 69 years old.  Suppose we have todaysdate = 18/04/2007

The minimum allowed date of birth would be 18/04/1991 and the maximum allowed date of birth would be 18/04/1938.  I have looked at using strtotime but this only does dates from 1970 (I think)




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Calculate Date Of Birth From Unixtimestamp
I am having a table that stores  datwe of  birth in  unix timestamp (now() for MySQL) . I want to display the name of all user along with their age. Can anybody help me in this?

Taking Date Of Birth From User And Sending It To A Mysql Database
i have created a form that takes a users date of birth as 3 seperate values $day $month and $year i do not know how to combine these values into a single value called $dob.
I tries using just a singal value to take the date however it did not work, even after I had formated my database.

Calculate Date
I have a date

11-07-2007 22:06

and i want to know how to calculate 4 hours ahead and create a count down system

$date_now
$date_4hours

$countdown = $date_now - $date_4hours;

How To Calculate The Day Of The Week By A Given Date.
I'm currently working on a (simple) calendar system which allows registered users to add an event to the calendar. The table EVENT stores info about the author, date and description of the event.

I then managed to output a list in which only events of this year are showed and are grouped together by months. And now I only need one more thing to complete the script. I want to output for every event on which day of the week it occurs (monday - sunday). I've looked around for tutorials but haven't found a basic one.

How To Calculate Date Difference?
Any one can suggest me how to calculate the difference between 2 dates and it shouldn't be more then 5 years. So pls tell me how to code this?

Calculate A Date Diff
Does anybody know of a script where I can calcullate a datediff and make a pop-up apear a week before a certain date.

Calculate Dates Given Beg And End Date
I am trying to figure out how to generate a listing of dates using the following known values:

begDate = 2007-07-03
endDate = 2007-08-30
recurDates = Tue|Thu

Question is how do I generate the YYYY-MM-DD for each of the dates between begDate and endDate for each of the recurDates?

Code To Calculate Date Range In A Given Week
Well I'm facing a problem in calneder and want your
help. I want to calculate the date that fall in a give
week but am not able to get the method for doing so.

Let me explain it with an example. Suppose i select
teh 25th week of the present year(i.e 25th week of
year 2006) then how can i calculate the days that fall
in that week.

Get Date Based On Weekday?
I have this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun created as links. What I would like to
do is to associate days with its current week dates, for example:

Mon (05.01.2004); Tue (06.01.2004); and so on.

Deleting A Field Value Based On Date?
How would I delete a field value in a mysql database every 24 hours? Anyone know?

Add To Date Based On User Selection
I have a form with Radio buttons that when selected should add "$howMuch" amount of hours to the current date and time and put the output into a field called "ExpireTime". The code I'm using for the hour adding: PHP Code:

Clause Based On Date/time
I have a database that returns a field with a date and time that looks like this:
12/04/2007 07:45:03

I need a simple clause that says if the time is before noon then A else if the time is after noon then B I could split the date from the time in a string then split the time by the : but there is a much easier way, right?

Displaying 'new' Icon Based On Date?
I'd like to display a little "new" icon next to all products in a directory which are, funnily enough, new! I've got a date (timestamp) for each product which is inserted on adding a new product and updating a product.

I'd like to do a conditional region using the timestamo but I'm not sure what to use - I could do === [current date] but that would only show the icon for that day and I'd like it to be there for about a week or so.

Generating Reports Based On Date/time Conditions
I need to generate reports in three ways:

I have a Date field in my database...

today
$query = 'SELECT * FROM 'table' WHERE Date = today';

Past seven days
$query = 'SELECT * FROM 'table' WHERE Date - 7';

Choose month( drop down preferably)

$query = 'SELECT * FROM 'table' WHERE Date = "'.$_POST['monthselected'].'"';

Get Most Recent Row On An Inner Join Mysql Query Based On Date
Here is my current query:

SELECT tbl1.id, tbl1.username, tbl1.status, tbl1.joined, tbl2.timeDate, tbl1.directory FROM tbl1, tbl2 WHERE tbl1.id = tbl2.users_id GROUP BY tbl1.id

This returns their oldest ie first login.  I use this for analytics on the backend to determine user activity.  So I would like a query that instead that returns the most recent tbl2.timeDate.

Auto Delete Date Based Calendar Events
Out of both wanting to improve my PHP skills and necessity, I created my own small CMS for a non-profit site I am involved with. One of the features I have is an event calendar where other users can submit  events, which then go into a "holding tank" until I can approve or deleted them. It's working great and everyone is loving it... but I have discovered one issue. When the date of the event passes, I have to log into the admin area and manually remove it. I am actually not deleting it from the database but changing a field variable and archiving it for our records.

I have been trying the past few days to come up with the necessary PHP to automatically check the current date (today's date) against all the calendar events and remove ones that have already happened. I could then hook this up to a CHRON action in my hosting CPanel and call it a day - at least that is how it all plays out in my head. 

I imagine in order to point me in the right direction you will need some information about my database.

EyeOS : Opensource Web Based Operating System Based On "php"
EyeOS is a Opensource web based operating system based on "php".

try demo here

http://eyeos.info/eyeOS/

Calculate Rank
I need to display the rank of my players.

The rank is based on this row: c_strength

What would I use to count their rank, ie:

Rank: 54 of 5,231

Calculate Total Of A Column
I have a column in mysql called price, and I would like to total the toal value of all items in that column, how do I do that?

Calculate Days Worked
I have a set date in my MySQL database that records when a Sales Lead
is established and I echo that date as $row_rsLead['lead_date'];

I need to be able to calculate how many days that lead has existed.
$row_rsLead['lead_date']; outputs as 2007-06-14.

I have made numerous attempts to create a function that will calculate
the days between the lead_date and today's date, but have made
absolutely no headway. I am either stuck working between differing
date formats or really strange numerical outputs.

If there is a script someone is willing to share or point me in a
direction that is good for a relative newcomer to PHP,

Calculate Volume Discount
I'm trying to create a calculation that will look at the qty ordered and compare that to the quantity discounts. An example is as follows.

Product = Bronco wild horses
1,000(horses) = $300.00/m
2,000 = $150.00/m
3,000+ = $100.00/m
etc.
/m=per thousand

So if I order 2500 horses the php page will look at the value entered, select the proper price and calculate the final total. 2500/1000=2.5X$150.00=$375.00 for 2500 Bronco's.
As you can see below, I've got the formating for the final total, But I don't know how to have it find the right price. Code:

How To Calculate The No. Of People Currently Browsing
how to calculate the no. of people is currently browser the first page in php programming???

How To Calculate The Running Time
The start and end times for a tv show or film .

17:50
18:30

40 minutes running time

23:50
00:30

40 minutes running time

23:50
01:40

110 minutes running time

Calculate Crc32 Of File In Php
I am having a problem calculating a crc32 hash of a file in php. I have uploaded a file, calculated an md5 hash and it is correct, both using md5_file() and hash_file("md5",filename) and they are both correct (tested with md5 command on osx and MD5 in Java). I am using hash_file("crc32",filename) and this gives a different result to crc32 in Java and crc32 command on osx.

Calculate A Firefighters Schedule In PHP
I need to calculate the following schedule in php. What I need out of the script is what shift is working “today” E.G. $shift = d;.  There are 4 shifts working 24hr days starting at 7 am. The days rotate on 28 day cycles. E.G.  ‘C shift’  is working on July 1 (Sunday) the next Sunday they work is the 29th. I found some code that works with 3 shifts on a different cycle but I have 4 shifts. Code:

Calculate Totals In A Loop
I am trying to calculate the totals of all the fields pulled up in a loop... i.e. I have a database called "checkout" that has bidder numbers, lot numbers, and amount for each lot number. When a person wins an auction (this is a live auction not an online auction) we enter a new row in the database that has the bidder number, the lot number, and the amount.

After the auction is complete and they are checking out we have the script pull all the rows where the bidder number equals the bidder who is paying, it displays their bidder number, and lists each lot number and amount for that lot on separate lines in a loop statement. I would like to have a final line at the end of the page that displays the total of all the amounts listed. I.e. if they have lot number 12 at $50 and lot number 10 @ $27 and lot number 55 @ $63 the script displays as follows...

bidder number: 101
lot number 12: $50
lot number 10: $27
lot number 55: $63

And I would like the end to say total: $140

How can I do this? I appreciate any help... Here is a copy of what I am working with now. Code:

Calculate Percentage Discount
I have a field which holds a numerical value lets say 29.99

Based on whatever the value of this number is I then want to calculate 5% of the value

Do I just do $discountPrice = $totalPrice * 5%

Im not sure what syntax to use to achieve this

Calculate Difference Between Dates
I've to build a function that tells me the resultant date from adding a number of days to a date. Example:

function adddate(date, days) {
     return date + days;
}

For example if I call with this...adddate(2007-05-05, 5) it should give back a 2007-05-10. I've tried but is hard! It should work with any number of days.

Calculate The Width Of A String In Cm
I use this script below to se how different texts looks with diffrents fonts.
Now I would like to know how wide the text is, in cm if you enter the hight of the text in cm, or viseversa. Code:

Calculate Number Of Days Between 2 Dates
How can I calculate the number of days between 2 dates in PHP?

Fedex Calculate Shipping Rate
Does anyone know how to calculate the shipping rate on Fedex? There
was a web module to handle the web query for rate at

Currently it is not available, I wonder if there still has a similar
module like that. I did some search on the Fedex sites and find out
they have several API and I do not know which one I should choose.
Could anyone give me some up to date idea on that?

Calculate A Number And Output It As An Image Using Img Tag?
Is it possible to point to a php file from an image tag like so:

<img src="http://otherdomain.com/getNumberOutputAsImage.php">

which would go to the php file, do its calculations, determine a number, then output that number as a graphic? Do you know what I mean?

P.S. now that I think of it, I have another thought. I heard that sites like doubleclick have their banner ads all over the place and using only the image tag, manage to set a cookie cross-multiple domains. Is this true? I have a couple of domains linked together and would love to be able to maintain the login state through a cookie. Is this possible?

Calculate Years And Months Of Service
I have each employees hire date stored in date format in MySQL (YYYY-MM-DD) and would like to calculate how many years and months of service they have.  The output would be like: Years of Service: 7 yr and 2 mo How would I go about doing this calculation?

Calculate Values From Drop Downs
I've been trying to get this to work myself all day long before posting here.

I want to create an order form which includes 2 drop down menus, StartLength and EndLength, the menu options for both being:

0-10 min
10-30 min
30-60 min

The respective values for each option are:

25
50
100

(the user should not see these values.) The total cost will be displayed and will be the average of the two values.

I've tried several different things, and nothing has really worked.
Here is the code I have at the moment.. Code:

Calculate Number Of Days Between Two Dates
I have people posting ads and when the ad is posted I have two fields populated at that time:

date_created
date_expired

With the date expired being 7 days after the date created. Both are in this format: 03/12/07

What I am doing is preventing someone from posting more than one ad per 7 days. I'm validating against their email address for that. But I want to display the date that they would be eligible as well as determine if they are eligible to post or not which would require comparing today's date with probably using the now() function against the date_expired in the database. If the today's date is past then no problem. If not, then it would display an error. Code:

Calculate Future Months [Reference Correction]
that ref fails for me after being googlegroupbeta'd... hopefully,
try this: http://groups.google.com/groups?th=613f743e0cf622f3

How To Calculate The Time The User Spend To The Webpage
I need a code that will calculate the time the user spend to the webpage. After specific timeline for example 1 minute, after 1 minute, the user will be redirected to login page.

Script To Calculate Correct Change From A Transaction.
The script would calculate the correct amount of change to return when performing a cash transaction. It must allow the user to enter two things:

(1) the cost of the transaction and
(2) the exact amount of money that the customer submits for the transaction.

You script will determine the largest amount of each denomination to return to the customer. Assume that the largest denomination a customer will use to pay is $100. You will need to calculate the correct amount of change to return using:

$50,
$20,
$10,
$5 and
$1 bills

as well as quarters, dimes, nickels and pennies. (For example, if the price of a transaction is $7.33 and the customer gives a $10 bill to the cashier,
the cashier should return $2.67.  This would be 2 one dollar bills, two quarters, 1 dime, 1 nickels and 2 pennies.

I was thinking about setting up 2 htlm pages. 1st one with two text boxes for input of:

1st HTML page:
1st box = totalprice
2nd box = totalcash

then the PHP code using a switch statement that would use the remainder to break down the dollar amount.

2nd html page:
Your change is:
values from the PHP code.

I think im heading in a right direction but I might need a little help. Do i need to use GET/POST method? Is switch statement ok? How and where would I declare all the values from $100 to pennies

How To Calculate Total Submitted Size Of HTML Form
I have a HTML form named "form1" and same as for form id if form as three element, elements can be Input->"text", File, Textarea, some buttons Now when i submit this form usinf submit button, I want to calculate total size of this form submitted using Javascript or any other way. How can i calculate total size of form in bytes / KB / MB.

Using PHP To Calculate MySQL Fulltext Relevancy Scores By Hand
Relevancy scores are normally defined by a MySQL query on a table that
has a fulltext index. The rules for relevancy scoring will exclude
certain words due to their being too short (minimum default is 4
letters).

This is the Fed. Everything is a TLA (three-letter acronym).

Therefore, since I'm building a PORTABLE web application, changing
MySQL's default settings for fulltext index querying is completely
undoable and unrealistic, so I created a "fake fulltext query", that
is, a plain query that masquerades as if it were a fulltext index
(only a lot slower but there is nothing I can do about it).

However, the client wants the exact same relevancy score as would be
found in a fulltext query. So I wrote a function that should
calculate the relevancy score based upon information provided by MySQL
AB's Sergei Golubchik. Here it is:

Code: ( php )

How I Calculate Total Time Taken By A Music File Which I Uploded
can you help me about the matter.

I have to show the music file lenth(time ex. time : 2:07). I can find
it in php have any function is there to cacultae that time.

Check Date From Input Must Greater Or Equal Today Date?
I have 3 select box. Code:

<select name="day">
<option value="1">1</option>
<option value="2">2</option>
.......
<option value="31">31</option>
</select>

<select name="month">
<option value="01"> Jan </option>
<option value="02"> Feb </option>
.....
</select>

<select name="year">
<option value="2002">2002 </option>
<option value="2003">2003</option>
</select>

When I select and click submit in form. I will have 3 variable :

$day, $month and $year

How can I check the day that I choose in form must equal or greater than today date? If it less than today date. I must print error message to user.

Date Is Not Being Pulled From MYSQL Database, Instead Current Date Is Displayed!
I am having trouble pulling a date from a database using PHP at the <a
href="http://www.mytuneslive.com/ameshkin69/"> following page.</a>

Here is the code. As you can see, it is just making the date the
current time. The values in the database are UNIX timestamp, and the
DATE() function is used to convert from UNIX to readable date. Can

<td width="55%" align="left" valign="top"><?php
$row_comment['timestamp'] = date("n d Y g:i A");.....

Trying To Calculate An Average Array From An 2d Data Array
I'm trying to calculate an average array from an 2d data array.
my problem is that my function does not generate an average array but just
one value. but i do not understand why it does not work.

code:
-----
function calculateAverageRating($rating_matrix)
{
$average_rating = array();
foreach($rating_matrix as $cus_id => $ratings)
{
$counter = 0;
$sum = 0;
foreach($ratings as $pro_id => $item_rate)
{
$counter++;
$sum += $item_rate;
}
echo $cus_id."->".($sum/$counter)."<br>";
$average_rating[$cus_id] = ($sum / $counter);
}
echo "<hr>";
echo "<table> <tr>";
foreach($average_rating as $key => $value);
{
echo "<td>$key::$value</td>";
}
echo "</tr></table>";
return $average_rating;
}

wanted:

input -> output

1 1 1 1
2 2 2 2
4 4 4 4

but my functions just does:

input -> output

1 1 1
2 2 2
4 4 4 4

Read Today's Date Print Tomorrow's Date
I've got a small script that writes a random number and the date to a text file. Then the script opens this text file and if date = date from this text file something must happen.
If something happened this script must open this text file again and replace it with a new random number and tomorrow's date.

<?php

$date = date("d-m-Y");
mt_srand((double)microtime()*10000000000);
$num=mt_rand(0, 20);
if ($num == $num && $date == "$tomorrowdate") { echo"$num -- $date";}
else
echo " ";?>

So if the script gets activated on the 05-05-2003 it must write tomorrow's date into the text file (06-05-2003). How will I get tomorrow's date today?

Help: Date Function Not Returning Correct Date & Time
I have just notices that the date() function is not returning the correct
date/time on my "server".

I am running apache2 on my winxp pro laptop.

My system clock is set to the correct date, time and timezone, get the
results returned by date() are 11 hours behind.

PHP Date Question: How To Determine The Date Each Of The Past 3 Sundays
How can I determine what the date was (in YYYY-MM-DD format) last
Sunday, and the Sunday before that?

For example:

Today is Thursday, August 18, 2004 (2004-08-18). I would like to have
the following variables:

$this_past_sunday = 2004-08-14
$two_sundays_ago = 2004-08-07
$three_sundays_ago = 2004-07-31

etc. etc.

Save Date To Table Field Date Type
I have a calendar picker on a form that fills a text box with  XX/XX/XXXX  date format. If I run a insert statement  the date field in the database shows 0000-00-00. If i change the field type to varchar  the correct format displays. 

What is the correct way to save a date to a mysql database?  Furthermore to query on the date  how about a select * from db_name where servicedate >= $startdate  and  servicedate >= $enddate  I supose this will not work
Any pointers?

Date Dropdown From Mysql Date Entries
For the PHP gurus out there, here is what I want to do: create a dropdown list of available dates from a mysql database date entries. But the dropdown/s should have 3 separate fields in month, day and year which in effect shows only those months, days and years that have corresponding entries from the database.

Planning to use this in the archive section of an online news publication so people can select issues to view via dropdown list that have corresponding entries only.


Copyright © 2005-08 www.BigResource.com, All rights reserved