PHP question

I have a very basic question - just started using cakephp and i am having trouble getting my index page to render.

I have two pages: 1 is the index page and one is the expiration page. I have a date set, and if the current date does not exceed the $expiration_date, the index page is supposed to render. I keep getting a 404 error - am I doing anything obviously wrong?
<?php

class ftaf2Controller extends AppController {
	/**
	 * @access	public
	 * @var		string
	 */
	public $name = 'ftaf2';

	/**
	 * @access	public
	 * @var		array
	 */
	public $uses = array(
		'Coupon'
	);
	
	/**
	 * @access	public
	 * @var		array
	 */
	public $components = array(
        'Session',
		'EmailDeployment'
	);

	/**
	 * beforeFilter callback
	 *
	 * @since	0.3
	 * @access  public
	 * @return  void
	 */
	public function beforeFilter() {

		$expiration_date = '2011-12-06 00:00:00';

		if (date('Y-m-d H:i:s') > $expiration_date) {
			$this->render('expired');
			exit;
		}

 public function index() {
		 } 
	
	}

?>

Open in new window

lvollmerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

seanmccullyCommented:
First you are not comparing dates  correctly, use the strtotime function to compare dates.
lvollmerAuthor Commented:
can you show me an example of what should be done?
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Chris Harte2015 Top Expert (Most Article Points)Commented:
You cannot compare date strings like that, convert them to timestamps

$expiration_date = '2011-12-06 00:00:00';

$ex_date = strtotime($expiration_date);

$now = strtotime(date('Y-m-d H:i:s'));

if ($now > $ex_date)
{
    $this->render('expired');
    exit;
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hugh McCurdyCommented:
MunterMan makes a good point.  I also think it would help you to learn if you saw what was going on.

Put these printf commands before your if statement.

printf ( "Raw now = %s<br />\n", date ( 'Y-m-d H:i:s'));

(If you are running PHP from the command prompt instead of using a web server, you can leave out the <br />)

printf ( "Cooked now = %s<br />\n", now );
printf ( "ex_date = %s<br />\n", $ex_date );
Hugh McCurdyCommented:
Oh, remove the printf statements after you understand what is happening.
lvollmerAuthor Commented:
thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.