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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:25:08+00:00 2026-05-29T13:25:08+00:00

I have premiere_poland column in database table which is date type. /** @Column(type=date, nullable=TRUE)

  • 0

I have premiere_poland column in database table which is date type.

/** @Column(type="date", nullable=TRUE) */
    protected $premiere_poland;

My issue is, that I want to store dates like 2012-01-01, 2013-00-00, 2013-01-00 etc. and I want that type of dates, but Doctrine every time returns that column data in DateTime instance and the true form is changed (for ex. 2013-01-00 = 31.12.2012).

How can I make Doctrine to return this value as a string, not DateTime class instance.

My query:

    $q = "SELECT
            g,
            p.name AS platform_name, p.name_short AS platform_name_short, p.id AS platform_id,
            s.premiere_poland, s.premiere_world
          FROM Game g
            JOIN g.genres ge
            JOIN g.platform p
            LEFT JOIN g.specification s
          WHERE g.id = :id";
    $results = $db->createQuery($q)->setParameter('id', $_GET['id'])->getResult();
  • 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-29T13:25:08+00:00Added an answer on May 29, 2026 at 1:25 pm

    @Crozin Because I need column which stores games date premieres and the premiere can be not fully known (for ex. March 2013 or only year).

    I would suggest to create two columns, one for a date (of type DateTime/DATE) and another that would indicate what parts of date (day, month, year) should be taken into account when displaying a premiere date (of type SET or a bit mask).

    Function that displays a premiere date could look like this:

    // "parts" is a name of the last column - it should be renamed into something
    // more adequate. Names of constants also aren't well adequate
    
    function getFormattedPremiereDate() {
        if ($this->abc & Game::SHOW_YEAR_ONLY) {
            return $this->premierePoland->format('%y');
        }
    
        if ($this->abc & Game::SHOW_YEAR_AND_MONTH_ONLY) {
            return $this->premierePoland->format('%m %y');
        }
    
        if ($this->abc & Game::SHOW_DATE) {
            return $this->premierePoland->format('%d %m %y');
        }
    }
    

    Of course this function shouldn’t be placed whitin an entity object – it’d be too complex (especially if we take i18n and i10l into account) and “unrelated” to the entity.

    This techinque should let you show following dates:

    • June 12, 2012 (12-06-2012, Game::SHOW_DATE),
    • 2015 (01-01-2015, Game::SHOW_YEAR),
    • March, 2012 (01-03-2012, Game::SHOW_MONTH),
    • Summer, 2020 (01-06-2012, Game::SHOW_SEASON), Winter, 2010 (01-12-2010, Game::SHOW_SEASON)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a database project in Visual Studio 2008 that has been working great.
Have a photography site that I want to prevent image copying from. How can
Have some dates in my local Oracle 11g database that are in this format:
We have InstallShield 2009 Premier installed on one system on which it is used
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have a question about access to object properties that will be used in
I have a very advanced header to select content. For the content I want
i have built a solution around google maps api but realized that it doesn't
I have a form that has multiple select drop downs. i.e. Item 1: <select
Ok I have a temporary table with 135000 rows, I'm trying to insert some

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.