1

I have a field in database (Time) with this value 09:00:00.

I created the Entity and with Time Field

 /**
 * @var \DateTime
 *
 * @ORM\Column(name="m_01_ch", type="time")
 */
private $m_01_ch;

In my controller I retrieve the element and when I do:

$val = $myentity->getM01Ch();

My value is (in XDebug)

$val = {DateTime}[3]
date= "2015-07-08 09:00:00.000000"
timezone_type = 3
timezone "Europe/Rome"

If I get $val->date I have All the Date, but I want to get only 09:00:00 Can I take my "original" value without use Regex etc?

monkeyUser
  • 4,301
  • 7
  • 46
  • 95

1 Answers1

3

You can modify your entity where you are returning your value. In your function getM01Ch() do something like this

/**
 * @return \DateTime
 */
public function getM01Ch()
{
    $returnValue = $this->m_01_ch->format('h:i:s') 
    return $returnValue
}

Other than that I don't know if any better approach exists. More info

Community
  • 1
  • 1
Dipen Shah
  • 1,911
  • 10
  • 29
  • 45