Search

What is the best way to store times in Symphony 2?

When using a date field always a full date will be saved (date + time). When using a text field the order is not numeric.

Is there an other way than creating a special time field, that just saves 08:00, 09:00 etc.
If not: How to create a time field? Is there any documentation concerning (field) extensions yet?

Nils

I just utilized the date/time field type. For instance, I have an events calendar on a site that I'm working on and I just enter the same date if the event starts and ends on the same day. Using the date-time utility in the default ensemble, it's very easy to output only the time.

What is your circumstance?

How about this?

The data is stored in the database as an total seconds value, so sorting should work correctly. You can input times as HH:MM or optionally with a seconds, HH:MM:SS. Datasource filtering supports ranges like so (seconds is optional):

HH:MM:SS to HH:MM:SS

If it works properly, I will post it up as an official extension release.

Hi Alistair,

thanks for the timefield. It is quite working, there is the following problem:

8:00 becomes 8:0:0 instead of 8:00:00
8:30 becomes 8:30:0 instead of 8:30:00

Nils

yeah, I kinda knew that was happening, but I got lazy. ;) Ill fix it up.

Ok. All fixed. The value should be correctly padded.

Thanks :)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details