Jump to content


Photo

Want form to accept future dates only


  • Please log in to reply
5 replies to this topic

#1 Corky1217

Corky1217

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 14 April 2011 - 01:59 PM

Hello, all. I am needing a little bit of help.

I would like to have a form that only accepts future dates, not current or past dates. I'm basically a PHP n00b, so I'm hoping someone can help me out.

Thanks.

#2 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 14 April 2011 - 09:00 PM

Simple:
1. time()
2. strtotime()

Then subtract the two and make sure the result is positive.

#3 Corky1217

Corky1217

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 14 April 2011 - 09:19 PM

I appreciate your reply, but can you go into a bit more detail?

#4 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 14 April 2011 - 10:53 PM

Do you already know how to handle posts in php? If not you should read: Variables From External Sources.

Also make sure you read the links i provided. Php.net is the best documentation site you'll ever find because it also provides some very useful examples with the doc.

#5 Wybe

Wybe

    Jedi In Training

  • Members
  • PipPip
  • 401 posts
  • Gender:Male
  • Location:the Netherlands
  • Interests:I have no interests

Posted 16 April 2011 - 06:41 AM

True that! What rc69's method does is it creates two (very large) numbers of seconds that have passed since the Unix epoch. It's kind of a clock, but a lot simpler because there's no oddities like 3600 seconds in an hour. You would calculate the amount of seconds up till the to-be-checked date, and compare it with the amount of seconds till now. If the first number is larger than the other one, you know the first date is in the future.

#6 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 16 April 2011 - 11:38 AM

I am trying to figure out what exactly it is he means? He wants a form to accept future dates? I suggest reading what rc69 posted, and learn the two php functions he submitted as well.. Can you give a bit more detail as to what exactly this form is going to do?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users