Link to home
Start Free TrialLog in
Avatar of Larry Vollmer
Larry Vollmer

asked on

PHP Date question

http://calendar.site.com/calendar.php?query=SearchCategory=&SearchDate=&SearchDateEnd=

I need to plug in the present days date here > &SearchDate=

and the date a week from the present day here &SearchDateEnd=

Can anyone help me out?
Avatar of hielo
hielo
Flag of Wallis and Futuna image

assuming you want the date as 2008-10-27:

echo "http://calendar.site.com/calendar.php?query=SearchCategory=&SearchDate" . date("Y-m-d",strtotime("now")) . "=&SearchDateEnd=" . date('Y-m-d',strtotime("+7 days"));

if you want m/d/Y then change:
Y-m-d

to:
m/d/Y
Avatar of Larry Vollmer
Larry Vollmer

ASKER

logically it works, but i have to put %2F  instead of slashes in between the date

IE today would look like:

&SearchDate=2008%2F10%2F27

$twoF = '%2f';
echo "http://calendar.site.com/calendar.php?query=SearchCategory=&SearchDate" . rawurlencode(date("Y m d",strtotime("now"))) . "=&SearchDateEnd=" . rawurlencode(date('Y m d',strtotime("+7 days")));

Open in new window

not clear what you mean but try:
echo "http://calendar.site.com/calendar.php?query=SearchCategory=&SearchDate" . urlencode(date("m/d/Y",strtotime("now"))) . "=&SearchDateEnd=" . urlencode(date('m/d/Y',strtotime("+7 days")));

Open in new window

Neither of those methods worked.

here is a sample of what the date string should look like:

&SearchDate=2008%2F10%2F27&SearchDateEnd=2008%2F11%2F3
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmm let me try again.
Wow that is weird. When I mouse over the link it puts slashes in, but when I click the link it uses the %F2 - thanks for the help.
you are welcome