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
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
            singleDatePicker: true,
            timePicker: true,
            showDropdowns: true,
            minDate: moment()
              .subtract(25, 'years')
            maxDate: moment()
              .add(25, 'years')
            locale: {
             [b] format: 'MM/DD/YYYY hh:mm A'[/b]
        ajax: {
          path: '/companies/add-activity',
          params: {
            company: companyId,
            proposal: proposalId,
          onComplete(resp, e) {
            if (resp.error) {
              return false;

            const companyIdDetails =
              companyId === 'bulk' ? : companyId;

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

      // show the form
      // eslint-disable-next-line no-use-before-define;

Open in new window

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?
David Johnson, CD
The More I know, the more I don't know
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
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