Solved

PHP Date question

Posted on 2008-10-27
9
393 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:lvollmer
  • 4
  • 4
9 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22813848
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
0
 

Author Comment

by:lvollmer
ID: 22814046
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
0
 
LVL 6

Expert Comment

by:trickyidiot
ID: 22814104

$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

0
 
LVL 82

Expert Comment

by:hielo
ID: 22814113
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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:lvollmer
ID: 22814161
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
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 22814239
>>what the date string should look like
I tested my last post and that is exactly what it does. Not sure if you are doing something else in your code.
0
 

Author Comment

by:lvollmer
ID: 22814314
hmm let me try again.
0
 

Author Closing Comment

by:lvollmer
ID: 31510363
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.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22814446
you are welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now