Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

I need to format this date! How?

Here's the way I'm inserting the date coming from an "update" function:

ajax: {
                        path: '/companies/update-activity',
                        params: {
                              company: companyId,
                              activityId: activityId
                        },
                        onComplete: function (resp, self) {
                        if (resp.error) {
                              self.addMsg(resp.msg);
                              return false;
                        }
                              if(dashboard=="yes") { //slightly different "success" message for the dashboard
                                    CAMS.alert('You have successfully updated your activity! Please refresh your page to see the changes.');
                                    return false;
                              }
                              else {
                                    $('#notes-'+activityId).text(resp.notes);
                                    $('#date-'+activityId).text(resp.date);
                                    $('#type-'+activityId).text(resp.type);
                                    CAMS.alert('You have successfully updated your activity!');
                                    return false
                              }
                        }
                  }

You see what's happening? I run my AJAX call and the data coming back from the update method gets inserted into the form giving the user the ability to feel like the pop up window reflects the changes they just made.

My challenge is that the format of the date needs to match what's going on in the app.

So, instead of the 4/18/2020 4:02 PM that you see in the date field...

User generated image
...it needs to read Apr 18th, 2020 4:02 PM

I tried this: b]$('#date-'+activityId).text(resp.date("M jS, Y \\a\\t g:i a"));[/b]

...but that didn't work.

What am I missing?
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As an addition to what I've just posted, one important thing I forgot to mention - you need to know exactly what is being passed back from your ajax call - i.e what is resp.date (is it a string / a date object / what's the format etc)