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!

trying to calculate any given upcoming monday based on a timestamp

Status
Not open for further replies.

dougleander

Programmer
Aug 29, 2003
2
0
0
US
i am trying to calculate any given upcoming monday based upon a timestamp lifted from a mysql database called Posted. here is some code that i have tried to manipulate. i can get it to calculate an upcoming monday based upon today's date but not based upon the Posted date. here is the code and description.

//this returns the date the record was inserted
//in the database and works fine!
$posted = strftime("%m/%d/%Y", $row['Posted']);
echo $posted;

//this returns the next monday based on todays date
//and works great!
function test_time($time_string) {
echo strftime("%m/%d/%Y", strtotime($time_string));
}
test_time('next Monday');

//this returns 01/05/1970 no matter what date is in Posted
//can anyone tell me why please!!!
//
function test_time($time_string) {
$nextM = strftime("%m/%d/%Y", strtotime($time_string, $row['Posted']));
echo $nextM;
}
test_time('next Monday');

thanks to whomever is the brilliant mind that rips my work to shreds & saves the day!!!

dje
 
The following line will return the date for next monday given the month day & year being placed in the appropriate places in the line, obviously you would use variables rather that hard-code as I have for testing purposes.....


$next_monday=strftime("%D",strtotime("next Monday",mktime(0,0,0,9,4,2003)));


Cheers - Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top