Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting a future '$wday'

Status
Not open for further replies.

blitzer

Programmer
Jun 18, 2001
34
0
0
CA
Im working on a calendar like script and I need to know future dates.. out of
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
the user selects $mday , $mon (+1), and $year but I would like the page they go to to show the $wday as well.. any ideas?

-blitz
 
Well...
You could, I suppose, set a base year and then each year additional the day of week for a date is one later (Thurs becomes Fri) except on leap years which it is two later (Thurs becomes Saturday).
As far as finding it in the first place, I would choose a base year where Jan 1st falls on a Sunday. By finding the number of the day (ie Feb 1st is the 32nd day of year) and rem 7, you can get the day of week (1= sunday, 2 = monday...0=saturday). This can work for years beyond the base year as long as the number of the day is in relation to Jan 1st of base year, not the current year. Does this make sense? --Derek

"Fear not the storm for this is where we grow strong."
 
the time() function returns a number of seconds since come date or other :), localtime() takes that and gives you a breakdown of that date.

The TimeLocal module does things the other way around, give date information and it will return the number of seconds since (etc) Mike
________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top