troubleshooting Question

How do I set the correct time in this code?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
JavaScriptNode.js
5 Comments1 Solution67 ViewsLast Modified:
I'm in a Nodejs application, I'm putting to together the data that's going to be displayed by "formit.js."

The code looks like this:

this.showActivityForm = (companyId, proposalId, type) => {
      const model = objectModels[type];
      const fc = model.singular.substring(0, 1);
      const config = {
        title: `Add a${
          fc === 'a' || fc === 'e' || fc === 'i' || fc === 'o' || fc === 'u'
            ? 'n'
            : ''
        } ${ucwords(model.singular)}`,
        directionsText: `Complete the form below to add a${
          fc === 'a' || fc === 'e' || fc === 'i' || fc === 'o' || fc === 'u'
            ? 'n'
            : ''
        } new ${model.singular}.`,
        fields: model.fields,
        onShow(e) {
          // add in the additional events and plugins
          // add in datetime support
          e.$el.find('input.field-datetime').daterangepicker({
            singleDatePicker: true,
            timePicker: true,
            showDropdowns: true,
            minDate: moment()
              .subtract(25, 'years')
              .startOf('hour'),
            maxDate: moment()
              .add(25, 'years')
              .endOf('hour'),
            locale: {
             [b] format: 'MM/DD/YYYY hh:mm A'[/b]
            }
          });
        },
        ajax: {
          path: '/companies/add-activity',
          params: {
            company: companyId,
            proposal: proposalId,
            type
          },
          onComplete(resp, e) {
            if (resp.error) {
              e.addMsg(resp.msg);
              return false;
            }

            const companyIdDetails =
              companyId === 'bulk' ? resp.data.id : companyId;

            $(window).trigger('open-company-details', [
              companyIdDetails,
              typeof route !== 'undefined' ? route : '/companies/',
              'history'
            ]);
            return true;
          }
        }
      };

      // show the form
      // eslint-disable-next-line no-use-before-define
      formIt.show(config);
    };

The piece that I have in bold is my challenge. The date is correct, but the time needs to be the local time. Right now, it's defaulting to 12:00 AM.

How do I fix that?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros