Simple Date Expiration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
protasov
Forum Newbie
Posts: 1
Joined: Mon Oct 02, 2006 9:55 am

Simple Date Expiration

Post by protasov »

For some reason I seem to be having trouble getting the right method to use for my problem...basically, I want to use an expiration date. For example, when a user tries to perform a button click, the system checks the date/time, and if its past a certain date/time, not allow it to continue, accurate to the second.

So I have a web page that allows for a login...if they attempt to login after Oct. 8 2006 1:00pm EST, then it won't let them....

Should be simple, but I can't seem to get it.

Any help is greatly appreciated....

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

<?php
$ts = strtotime('Oct. 8 2006 1:00pm EST');
if (time() > $ts) {
	die ('login not allowed after '. date('d.m.Y H:i:s', $ts));
}
?>
see http://de2.php.net/strtotime
User avatar
hanji
Forum Commoner
Posts: 46
Joined: Fri Apr 29, 2005 3:23 pm

Post by hanji »

Do you have any code to show? I think you'll want to look at mktime()

Thanks
hanji
User avatar
hanji
Forum Commoner
Posts: 46
Joined: Fri Apr 29, 2005 3:23 pm

Post by hanji »

volka wrote:

Code: Select all

<?php
$ts = strtotime('Oct. 8 2006 1:00pm EST');
if (time() > $ts) {
	die ('login not allowed after '. date('d.m.Y H:i:s', $ts));
}
?>
see http://de2.php.net/strtotime

I like that!
hanji
Post Reply