3

i have a list of movie screenings sorted by date. now the client wants to be able to order additionaly with a custom order field, i don't get to the second order_by however...

it seems when you enter a date random seconds are added to the EE timestamps. if they enter "2013-03-01 08:00 PM" it always has a different timestamp: 1362186000, 1362186018, 1362186025, 1362186032,...

where are those seconds coming from? and how can i solve it?

my template:

{exp:channel:entries channel="screenings" status="open" dynamic="off" category="3&21" orderby="screening_datetime|screeningorder"  sort="asc|asc"  limit="200"}
            {screening_datetime} - {screening_datetime format="%d %M %Y  %G:%i"} hrs {screeningorder} 
            {related_entries id="screening_movie"}
                <a href="{title_permalink="programacion/pelicula/"}">{title}</a> 
            {/related_entries}
{/exp:channel:entries}  
4

Since by default the datepicker does not include seconds, EE saves the current time's seconds (minus 1 second) to the entry date (and in fact any custom date field). So the last part of the timestamp for each of these fields is based on when the entry was created.

(Looking under the hood, it appears there have been two approaches over the years to this - at one time, seconds were set to 00, but then this was reverted, as it meant that entries submitted within the same minute had identical timestamps, which is not accurate.)

You can use the hidden configuration variable include_seconds to your config.php file to add the seconds to all datepickers, allowing you to set the date precisely.

$config['include_seconds'] = 'y';

Or, since this is a custom date field you're using (not the Entry Date), you can use DropDate, which bypasses EE's date handling and saves the timestamp directly, using 00 for the seconds value.

1
  • hi derek, the $config['include_seconds'] = 'y' worked perfectly. thanks!! – Dave Driesmans Feb 11 '13 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.