0

I have the following code, but currently experiencing format has no method. It is completely working off another site because i used the exact same code for reference. Now i am unsure why it didnt work for my site when i copied it over.. Can anyone help me out?>

 var TodayDate = new Date();
    TodayDate.setDate(TodayDate.getDate());

    var PastDate = new Date();
    PastDate.setDate(PastDate.getDate() - 30);

    StoreHeavyTraffic = 0;
    StoreRoadWork = 0;
    StoreVehicleBreakdown = 0;
    StoreAccident = 0;
    StoreObstacle = 0;

    var PD = Date.parse(PastDate.format("d MMM yyyy"));
    var TD = Date.parse(TodayDate.format("d MMM yyyy"));
3
  • Native date object doesn't have a method called format. You might be missing a library at your site. Commented Apr 3, 2014 at 14:33
  • it seems a momentjs method momentjs.com Commented Apr 3, 2014 at 14:35
  • yes i know that , the other reference source i copied from has jquery.js, jquery-ui.js Commented Apr 3, 2014 at 14:35

1 Answer 1

1

Date is a native javascript object and it doesn't have a format method. The method you are trying to use looks like moment's format method which also cannot be called on native Date objects

Sign up to request clarification or add additional context in comments.

5 Comments

it works completely fine from the reference site i copied from, and its the exact same coding.. Not sure what i am missing out.. can you help me out?
What's the reference site?
its abit complicated. It can only run from my office network.. I have the same exact source on my machine but it cannot run due to proxy error. would you mind teamviewing me for awhile?
You must not have downloaded all of the javascript, and if they extended the native Date object, it's worth looking into doing it the right way using a library like momentjs (many examples of what you are trying to accomplish on moment's homepage).
I dont think its moment.. I have ran the debug console for many hours but to no avail, as well as comparing the reference scripts.I am trying to keep the code as close as possible to the reference site. Would you mind teamviewing me for a short while? help me greatly appreicated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.