Get The Time From Database in Symfony 2


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?


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 <a href="https://stackoverflow.com/a/30381309/4841794" rel="nofollow">info</a>


  • Mapping MySQL JSON column to hibernate value type
  • Entity framework filter lambda navigation properties
  • Cannot use Turkish characters with Entity Framework
  • CSS Grid, position absolute an element in a css grid item: IMPOSSIBLE
  • getelement by class name for clicking
  • Python/Javascript: WYSIWYG html editor - Handle large documents fast and/or design theory
  • Is there a package like bigmemory in R that can deal with large list objects?
  • Knockout custom binding handler
  • Why isn't obj.style.left = “200px”; working in this code?
  • CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
  • Hide HTML elements without javascript, only CSS
  • Python pickle not one-to-one: different pickles give same object
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • C: Incompatible pointer type initializing
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • Sencha Touch 2.0 Controller refs attribute not working?
  • jQuery .attr() and value
  • Can I display google adwords (AdView) in javafx on android
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Javascript + PHP Encryption with pidCrypt
  • Weird JavaScript statement, what does it mean?
  • How do I rollback to a specific git commit
  • bootstrap to use multiple ng-app
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do I configure my settings file to work with unit tests?
  • Getting Messege Twice Using IMvxMessenger
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • apache spark aggregate function using min value
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Django query for large number of relationships
  • Binding checkboxes to object values in AngularJs
  • How can i traverse a binary tree from right to left in java?
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • How to load view controller without button in storyboard?