Link to home
Create AccountLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

How do I set the correct time in this code?

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?
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Bruce Gust


You know what, David? Then I'm going to eliminate the time portion.

To my opinion it is better to manage the time in a seperate field.

There are some plugins that have date and the time 

You know what? This problem is happening elsewhere as well. Let me put together another question and give you the chance to weigh in on it.

Stand by...

Avatar of azeem ali
azeem ali

Actually I have checked the above section there is no mention data main thing to want to exact data also current date using javascript JavaScript Date Format mm/dd/yyyy 
var date_format = new Date(); 
document.write(innerHTML = date_format.getMonth()+'/'+ date_format.getDate()+'/'+date_format.getFullYear());

Open in new window