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




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.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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.

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 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?

Getting Day Of The Week From A Date
I tried searching the old postings, but to no avail. I am trying to figure out a way to get the day of the week from a date. Basically, I have a date in the format of 05/02/2003 (but I can change that format easily) and I need to have my program figure out which day of the week that was. All of the dates that I have will have already passed.

Date Of The Week
Can anyone help me? I am trying to work out the timestamp for the first DATE (not day) of the current week and last date of the current week. Any ideas?

Date To Week # Fct
I'm searching a PHP function that would translate a date in the following
format yyyymmdd to the week number in the year...
ex : 20040128 => 5
i.e. jan 28th 2004 gives week nb 5 in 2004.

Week Before Date
Im looking to get the date 7 days ago. I know how to do 7 days ahead:

$timeStamp = strtotime($oLastBatchDate->Last);
$timeStamp += 24 * 60 * 60 * 7;
$NextBatchDate = date("Y-m-d  H:i:s", $timeStamp);

However, does anyone know how to do 7 days back?

Date And Week
I am looking for a way to determine the week of the year if i have a date.i know that
date("W"); give me the week Number but not sure how to determine the week based on the date.

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?

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)

Date Of The First Day From A Given Week Number
I need some help to figure out the date of the first day in a given week number. Let's say that I pick week number 23, I want to retrive the day of that monday in week 23..

I've been searching the net for days without any result.

Date Out Of Week Number?
I would need to get a date out of a week number, for example for week 52 the first date, 25/12. In my system the user inputs a week number, and then I would like to display a popup list of all seven dates for that week, for her to choose from. Is there a handy function to do this, or can you think of any way to achieve this?

Date Function For Week Before
Im looking to get the date of a week before a certain date For example:

      $iLastDate = date("Y-m-d H:i:s ");
      $timeStamp = strtotime($iLastDate);
      $timeStamp + = 24 * 60 * 60 * 7;
      $NextBatchDate = date("Y-m-d  H:i:s", $timeStamp);

This is for a week ahead, how do I do a week before?

Work Out Day Of Week From Given Date
I'm using a date picker to choose a date. the format of the date entered into the textbox is yy/mm/dd

From this how can I work out the day of the week from the entered date? I need this as the first day has to be a sat, and if it isnt my form will tell the user to choose a saturday.

Is there a simple way of doing this?

Getting Day Of Week From User Defined Date?
is there a way to do this? e.g. i have three drop down boxes in html asking the user for day (1-31), month, year (2007 or 2008) i then have:

// get user input
$start_day = $_POST["start_day"];
$start_month = $_POST["start_month"];
$start_year = $_POST["start_year"];
//echo $start_year;

$the_date = $start_day . "/" . $start_month . "/" . $start_year; echo $the_date; say then i get an output as 13/10/2007 if the user enters that date, is there a way to get what day of the week this is?

Using The Date Function To Find Last Week Start And End.
I need to find the start of last week (monday) and the end of last week (sunday) using the date function in a Y-m-d format.

But it needs to work this out regardless of todays date.

Finding a day in the past is not a problem if you know how many days to minus from the date function, but how can I work this to be not dependent on this fact?

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

First Day Of A Week
hi,

i want to know the range of date for a week

example : week 3 of 2001

monday is ??
sunday is ??

how can i do with PHP ??

tx

Day Of Week ?
Is there a way I can obtain the day of week - If I have the day, month, year ?

(not via the time function - But from a database....)

Im looking through the calendar and date functions -But can't locate
anything suitable...

Day Of The Week?
is there a way to get the day of the week in php? i want to get the correct values monday, tuesday, wdenesday, etc. for the actual day it is.

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:

Getting Day Of Week Out Of Datestamp
I currently have a datestamp in the format yyyymmdd. I want to pull the day of the week (Monday, Tuesday, etc...) out of that datestamp at any given time.

Currently my code looks like this:
$datearray = getdate($firstdatestamp);
echo $datearray["weekday"];
When $firstdatestamp = 20000501 (or the first of May, 2000) the weekday returned is Thursday when really it should be Monday!

I tried:
echo date("l", time());
and it gives me the right weekday but only for the current date. I need to pass this my datestamp and am not too sure how.

Week Of Year
Is there a function which returns the week of the year, given a specific date?

Getting SQL Rows For A Week
I have a database that uses two date fields for tracking information. The first field is for the addition of the record and the second is for the expiration.

I have a small section that I want to list records that will expire in the current week (or for that matter in the next 7 or 14 days). What is the syntax that I would use to call mySQL with to get that info.

Week Of The Month
I need to determine the week of the month (1-5) so I can rotate menus for a cafeteria.
Is the following, which I know prints the week rather than storing it, the simplest or easiest way to determine the week? PHP Code:

File Of The Week?
I wish to add an automated "file of the week" feature to a site for users to download.
I was having a little trouble explaining this.... So I ended up making these few points on the functions of the script I'm aiming for:

- The script finds the folder with the files for the current week. (If the download was a wallpaper, there would be files for different resolutions, and therefore more than one file.)

- Links are then made to the files.
- Every week, the links are updated for the new files for the current week.

I was thinking along the lines of putting the weekly files into folders named after timestamps and going from there... Is that the way to go? And how would it be done? I can't quite figure this out.

Printing Every Week
im trying to print a list of every Friday since a date defined. Let me try and explain. I want to define a date such as 2007-07-06 (which is a Friday) and then let php print each Friday since that date until today. For example, if the date defined was 2007-07-06 then it would print

2007-07-06
2007-07-13
2007-07-20
2007-07-27
2007-08-03
2007-09-14

But I want to also be able to format the date it outputs, so it might look like

Friday 06 July 2007
Friday 13 July 2007
Friday 20 July 2007
and so on.

Day Of The Week Program
I am trying to write a program that will give me the day of the week without using the date function. I input the date and it's supposed to spit out the name of the day of the week. Here is what I have so far. I don't know quite what to do next. 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:

Datetime Within Past Week
I have a series of records in a database. When each record is stored,
the datetime is logged: $date = date("Y-m-d H:i:s");

Prior to adding a new record to the database, I want to run a query to
retrieve all of the records uploaded in the last 7 days. I thought it
would be easiest to:

Pseudo Code:
$newDate = $date - 7 days;
select * from TABLE where DATE $newDate;

Problem is I can't figure out how to subtract 7 days from $date and
convert that value to a valid datetime object.

Current Week Number
how I can split the month out into 5 weeks... then to have the week number printed and when the current week ends it will increment to the next week number. For example today is 3rd of July, therefore we are in week 1 of the month. Next week will be week two. I want it to go back to 1 at the start of the next month though.

Handling Week Number
I have been reviewing some calenders classes and have notice that if u
uses us written class with displays week number it ll by wrong for eu.
so to my question
how do you handle week numeration depenting on country? is there any
simple solutions for this?


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