View Full Version : date headache.

12-05-2010, 07:51 PM
Hi there.

I'm trying to create my own search function for users to search for events between certain dates. One option I have is 'within next 7 days'.

So, within the SQL function I am searching "... WHERE eventdate between $from and $to.."

The $from variable I figured would be $from = date('d-m-Y',time()); (ie- todays date)... but how would I find the date in 7 days?. I've seen strtotime mentioned about the web but can't figure how this applies.

Any help would be marvelous! :thumbsup:


12-05-2010, 09:15 PM
$timenow = time();
$timeinaweek = strtotime('+7 days');

12-05-2010, 09:21 PM
Brilliant, thank you.

Also, is there anyway to find the date this weekend as well, ie - a strtotime('thisweekend') sort of thing, to find the date of the closest Saturday.

12-05-2010, 09:26 PM
strtotime('next Saturday')

12-05-2010, 09:26 PM
date('w') should return the day of the week, 0 being Sunday, so...

$saturday = strtotime('-'.(date('w', $datetoprocess)+1).' days', $datetoprocess);

Untested, though something like that.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum