Setting date-time fields

rss

Posted by marcwenger - Feb 17 ’14 at 07:31

How does one set, in javascript, the date, hour and minute fields?  Are there special break characters in a string or Date object?  Thanks

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 11 months
    #1 by Dmitry Kozlov Feb 18 ’14 at 03:57

    Hello,

    You should pass an array into date and time field:

    fd.field('DateTime').value(['3/19/2014', '9 AM', '40'])
    
  • davidnarramore
    Member
    Member for: 4 years 6 months 30 days
    #2 by davidnarramore Apr 9 ’15 at 11:34

    Can the time range be set?  Instead of 24 hours 8am 8pm?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 11 months
    #3 by Dmitry Kozlov Apr 10 ’15 at 05:47

    [#2]: Hi,

    You can change time format in the regional settings of the site:

    Site Settings -> Regional settings -> Time format.

     

  • davidnarramore
    Member
    Member for: 4 years 6 months 30 days
    #4 by davidnarramore Apr 10 ’15 at 06:06

    I am talking about the control on the list forms only showing options from 8am to 8pm. The regional settings are set from 8am to 8pm, but the date time picker still shows full 24 hour time period.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 11 months
    #5 by Dmitry Kozlov Apr 13 ’15 at 03:51

    [#4]: Got it. You can remove redundant options with the help of JavaScript:

    fd.field('DateTime').control()._el().find('select:eq(0) > option').filter(function() { return $(this).index() < 8 || $(this).index() > 20 }).remove()

    Replace DateTime in the code above with the internal name of you date and time field.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 11 months
    #6 by Dmitry Kozlov Apr 13 ’15 at 03:51

    [#4]: Got it. You can remove redundant options with the help of JavaScript:

    fd.field('DateTime').control()._el().find('select:eq(0) > option').filter(function() { return $(this).index() < 8 || $(this).index() > 20 }).remove()

    Replace DateTime in the code above with the internal name of you date and time field.

Displaying 1 to 6 of 6 messages