ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

entry_date off by one minute

October 12, 2011 5:36pm

Subscribe [3]
  • #1 / Oct 12, 2011 5:36pm

    Mason N

    17 posts

    Running EE 2.2.2.  I have a SafeCracker form which allows the user to set date and time of an event, and use JS to concatenate that into a string to be used for entry_date:
    2011-10-13 07:00 PM

    Sometimes (not every time), the time gets set as 6:59 instead of 7.  Does anyone have a guess where I would start looking for something like this?  I’m forcing everyone to use the super admins time zone (CST), is there some conversion that occurs that could explain being off by one minute?

  • #2 / Oct 12, 2011 8:45pm

    ejaedesign

    240 posts

    This sounds like the server time itself being off, which was the case with our dedicated host. I had to adjust the difference by adding +xx (where xx is the number of minutes that are off) in the localization settings.

  • #3 / Oct 13, 2011 8:08am

    Sue Crocker

    26054 posts

    Thanks for the assist, ejaedesign.

    Mason, might that be the issue?

  • #4 / Oct 13, 2011 9:43am

    Mason N

    17 posts

    To be honest, I’m not sure how I would check that, or why it would make a difference.  I’m passing entry_date = “2011-10-13 07:00 PM” when I create the entry and getting 6:59 (intermittently).  The site is on EngineHosting.  How would I go about verifying my server time, and what time would it be different from that would cause this issue?

  • #5 / Oct 13, 2011 12:47pm

    Mark Bowen

    12637 posts

    Hi Mason,

    You mentioned using Javascript here to set the time automatically. I’m not great with Javascript but I don’t believe that it would be using any of the settings in ExpressionEngine in order to set the time here would it?

    Wouldn’t a time set by Javascript be reliant upon the computer which is viewing the site at that time?

    Actually as a test if you install this script located here - http://www.dynamicdrive.com/dynamicindex6/localtime.htm does the time show up correctly for the server or do you get something unexpected?

    If unexpected then you would need to have a word with your host as to why this is.

    Thanks,

    Mark

  • #6 / Oct 13, 2011 1:22pm

    Mason N

    17 posts

    That script shows the time just fine, and it’s as expected (matches my own computers time to the second).

    Mentioning the JavaScript was probably a distraction.  The user is presented with a date field, and pull downs for hour, minute, and AM/PM.  After making their selections, I concatenate the fields into one field, as so:
    $(‘input[name=entry_date]’).val( $(’#start_date’).val() + ’ ’ + $(’#hour’).val() + ‘:’ + $(’#minute’).val() + ’ ’ + $(’#ampm’).val() );

    So it’s setting the entry_date to exact values, and not doing any extra math that might remove 60 seconds.  Also, the nature of the entries means we never want to change that entry_date, so I don’t think it’s somewhere else in the code.

    Out of the 70+ times the form has been submitted, the problem has occurred about 4 times. Every time it has happened, the user was attempting to set the time to the top of the hour (7:00 or 6:00), and it ends up being one minute sooner than they intended.

    I had thought it might be some strange rounding error, where the system is converting to GMT and back, but I guess it’s pretty far-fetched to think that people wouldn’t notice that, so I guess close this and I’ll work harder on reproducing the issue.

    Thanks.

  • #7 / Oct 13, 2011 3:01pm

    Mason N

    17 posts

    Oh, wild.  So I made a page (on a different server, though I don’t think that matters) that contained nothing but this:

    {exp:safecracker channel="event" return="behind-the-scenes/test" id="create-event-form" include_jquery="no"}
    <input type=“text” value=“Event at 12:00PM” name=“title”/>
    <input type=“text” value=“2011-10-13 12:00 PM” name=“entry_date”/>
    <input type=“submit”/>
    {/exp:safecracker}

    And then I hammered on the submit button, clicking it as fast as I could about 30 times.  Then I went to check the entries, and I had created 11, and 2 of them have the time of 11:59.  Riddle me that, batman.

  • #8 / Oct 13, 2011 3:24pm

    Mason N

    17 posts

    On advice from MediaGirl, I added datepicker=“no” to the safecracker call and cannot reproduce in my test page.  I’ll try to figure out what datepicker is doing.

  • #9 / Oct 13, 2011 4:44pm

    Mason N

    17 posts

    Oh, I tested more, removing safecracker_head, jquery, and datepicker, and it does still happen.  Guess I didn’t test thoroughly enough:
    {exp:safecracker channel="event" return="behind-the-scenes/test" datepicker="no" safecracker_head="no" include_jquery="no" id="create-event-form" include_jquery="no"}
    <input type=“text” value=“Event at 12:00PM” name=“title”/>
    <input type=“text” value=“2011-10-13 12:00 PM” name=“entry_date”/>
    <input type=“submit”/>
    {/exp:safecracker}

  • #10 / Oct 14, 2011 11:02am

    Mark Bowen

    12637 posts

    Hi Mason,

    I just tried this in a few installs of ExpressionEngine and all times and dates go in as expected with a standard Safecracker form using hard-coded times as you’ve shown above.

    You have everything set up correctly as far as I can tell though.

    As you mentioned that this only happens sometimes and not all is there anything that is different when this happens?

    I wouldn’t have thought that the server time or offsets would have much to do with this as you are hard-coding the times, might be though so you may want to check with your host that nothing’s off there perhaps?

    Thanks,

    Mark

  • #11 / Oct 14, 2011 12:08pm

    Mason N

    17 posts

    Thanks for taking the time to try to reproduce the issue, I appreciate it.

    I updated my staging server to 2.3.0 last night (from 2.2.2), and can no longer reproduce the issue.  I don’t know if this is at all related; but whereas before, when I clicked submit 30 times I might get 10 events, now I only get two.  Not sure if the system is just running more slowly, or what.  But I can no longer generate an 11:59 time.

    For now, I updated the public facing display code to round times to the nearest quarter hour, but I’ll update the live server EE to 2.3.0 as soon as I can and hope that addresses it.

    Thank you.

  • #12 / Oct 14, 2011 12:11pm

    Mark Bowen

    12637 posts

    Hi Mason,

    I’m not quite following what you have written above. You said you can no longer reproduce the issue so is everything okay now?

    Thanks,

    Mark

  • #13 / Oct 14, 2011 12:12pm

    Mason N

    17 posts

    Yes. Upgraded to 2.3.0.  Can no longer reproduce the issue.  Everything is ok.

  • #14 / Oct 14, 2011 12:15pm

    Mark Bowen

    12637 posts

    Hi Mason,

    Excellent news. Glad that’s got you sorted. Not too sure what the problem was there though as I couldn’t reproduce on a fair few versions of ExpressionEngine though.

    If anything else crops up then please don’t hesitate to post again as needed.

    Cheers,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases