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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:09:54+00:00 2026-06-15T19:09:54+00:00

I am creating project in yii. I am having Poll table with the fields

  • 0

I am creating project in yii. I am having Poll table with the fields as-
-pollId
-pollQustion
-isActive
-publishDate

I want to check weather publishdate of poll is not greater than current date.
I am implementing as-

$CurrrentDate=new CDbExpression('NOW()');
if($record->publishDate < $CurrrentDate))
{
  some code......
}

But its not executing correctly. Code is executing even if publish date is greater than current date. So how to make this comparison in yii framework. please help me

  • 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-06-15T19:09:55+00:00Added an answer on June 15, 2026 at 7:09 pm

    PHP do not have a date format. When you compare $CurrentDate and $record->publishDate you compare strings. Well, for right compare you need to convert it to Unix’s timestamp

    // here you set right date/time pattern 
    // You need to explain CDateTimeParser for your pattern
    // just easy use `strtotime` if you have 2012-12-12 12:12:12
    $publishTimestamp = strtotime($record->publishDate);
    // $publishTimestamp = CDateTimeParser::parse($record->publishDate, 'yyyy-MM-dd hh:mm:ss'); 
    // if you need to use Hours and minutes just easy use `time()`
    $currentDateTimestamp = time();
    // $currentDateTimestamp = strtotime(date('Y-m-d H:i:s'));
    // now we can compare
    if ($publishTimestamp  < $currentDateTimestamp) {
       // do some 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating project in yii framework. I am having table as- Qbquestion QbquestionOption
In yii i am creating project. Now i want to create widget for displaying
When creating a project with the webapp archetype in Maven, they subtly advise not
I am creating a project that only uses client side languages. I want to
I am creating a setup project and want to remove the option to install
When creating a project in applications/xampp/htdocs using the yii framework in terminal, it's showing
In yii i am creating project. After validation of user's entered email, i am
I am creating project in Yii framework. In controller i have function as- public
I am creating a project, in which i want to use this open source
I'm creating a project in flex builder but it's not using the flex framework,

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.