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 687989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:11:01+00:00 2026-05-14T02:11:01+00:00

In Magento I’m creating a custom module and would love to be able to

  • 0

In Magento I’m creating a custom module and would love to be able to filter automatically by the datetime column so that the intial grid listing shows only entities related to “todays” date.

Here is my datetime column:

$this->addColumn('ts', array(
    'header'    => $hlp->__('Activated'),
    'align'     => 'left',
    'index'     => 'ts',
    'type'      => 'datetime',
    'width'     => '160px',
));

I’m think there should be a way for me to just add a filter to the collection like so:

$now = Mage::getModel('core/date')->timestamp(time());
$dateTime = date('m/d/y h:i:s', $now);

$collection = Mage::getModel('mymodule/items')->getCollection()
   ->addFieldToFilter('ts', $dateTime);

But this doesn’t work?

Am I using the wrong filter? My “ts” field in the database is a “datetime” field, but the default magento “From: ” – “To:” date range selectors don’t use hours, minutes, seconds.

Any ideas?

Thanks,
Tegan

  • 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-14T02:11:02+00:00Added an answer on May 14, 2026 at 2:11 am

    This seems to work. I had my time formatted incorrectly.

    $now = Mage::getModel('core/date')->timestamp(time());
    $dateStart = date('Y-m-d' . ' 00:00:00', $now);
    $dateEnd = date('Y-m-d' . ' 23:59:00', $now); 
    
    $collection = Mage::getModel('mymodule/items')->getCollection()
       ->addFieldToFilter('ts', array('from' => $dateStart, 'to' => $dateEnd));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In magento i created a custom module and completed the template and controller part,
Is Magento somehow unique in a way that would make the (now becoming a
Magento 1.7.0.0 ok i'm using the product tabs that are available in the modern
Magento site is not updating the price according to the custom option added. I
(Magento Version 1.6) I'm trying to display a custom category attribute I created to
Magento checkout broken in IE9 and IE8 for that matter When testing our checkout
Installed Magento 1.6.2.0, and noticed that the links are like http://MYSEUPERSTORE.com/ index.php /customer/account/ but
My Magento site has a product which has a few Custom Options, one text,
In magento I have started to set up an admin module and am not
Magento has a rich Sales module with a ton of options, and it's well-documented

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.