Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6477013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:53:45+00:00 2026-05-25T06:53:45+00:00

I have a deals table, with a field start date in the controller i

  • 0

I have a deals table, with a field start date in the controller i am trying the below code and it is not returning any deal when there is deals with these conditions

Here’s the codes:

function todays_deal($CitySlug = null) {

        $city = $this->City->find('first', array('conditions' => array('City.slug' => $CitySlug)));
        $CityID = $city['City']['id'];
        $now = date('Y-m-d H:i:s');
        $conditions = array(
            'Deal.city_id' => $CityID,
            'Deal.type' => 'F',
            'Deal.start >=' => $now
        );

        $deal = $this->Deal->find('first',array('conditions'=> $conditions, 'order' => 'Deal.start DESC'));
    $left = array();
        $now = time();
        //Change dates to timestamp
        $end = strtotime($deal['Deal']['end']);
        $start = strtotime($deal['Deal']['start']);
        if($end < $start){
            $end = $start;
        }

        $diff_time = $left_time = $end - $now;

        if ($start >= $now ) {
            $diff_time = $left_time = $start - $now;
        }

        $left_day = floor($diff_time/86400);
        $left_time = $left_time % 86400;
        $left_hour = floor($left_time/3600);
        $left_time = $left_time % 3600;
        $left_minute = floor($left_time/60);
        $left_time = $left_time % 60;

        $this->set(compact('deal', 'left_day', 'left_hour', 'left_minute', 'left_time', 'now', 'diff_time'));

    }

I am totally lost to why this isnt returning any deals as it should.

All help appreciated

Thanks
Dave

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:53:46+00:00Added an answer on May 25, 2026 at 6:53 am

    If you turn up the debug level in CakePHP, it should dump out the queries used.

    Check the SQL generated for your select – perhaps the date format is the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to deal with a table where there is a set of fields
Let's say I have a table that has a varchar field. If I do
I have a stored procedure that inserts into a table (where there is an
i have two tables: CREATE TABLE public.auctions ( id VARCHAR(255) NOT NULL, auction_value_key VARCHAR(255)
Im trying to get my head around MySQL. I have learnt a great deal
I have a field named 'dealBusinessLocations' (in a table 'dp_deals') which contain some ids
I have a table with different offers which are bound to a specific date.
I have a table in SQL Server, tblMain. There's a trigger that when a
I have a table called deals which stores client_id1 , client_id2 , client_id3 .
I have an ai_order table. CREATE TABLE `ai_order`( `id` INT(11) NOT NULL AUTO_INCREMENT, `product_id`

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.